Skip to content

Commit 437a2e5

Browse files
committed
HHH-17803 Add test for issue
1 parent 024fd31 commit 437a2e5

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

hibernate-core/src/test/java/org/hibernate/orm/test/hql/InSubqueryPredicateAnonymousTupleTest.java

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import jakarta.persistence.Convert;
2020
import jakarta.persistence.Converter;
2121
import jakarta.persistence.Entity;
22+
import jakarta.persistence.EnumType;
23+
import jakarta.persistence.Enumerated;
2224
import jakarta.persistence.Id;
2325

2426
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,12 +35,13 @@
3335
@SessionFactory
3436
@Jira( "https://hibernate.atlassian.net/browse/HHH-17332" )
3537
@Jira( "https://hibernate.atlassian.net/browse/HHH-17701" )
38+
@Jira( "https://hibernate.atlassian.net/browse/HHH-17803" )
3639
public class InSubqueryPredicateAnonymousTupleTest {
3740
@BeforeAll
3841
public void setUp(SessionFactoryScope scope) {
3942
scope.inTransaction( session -> {
4043
session.persist( new BasicEntity( 1, "test" ) );
41-
session.persist( new TestEntity( 1L, new Money( 100L ) ) );
44+
session.persist( new TestEntity( 1L, new Money( 100L ), Status.VALID ) );
4245
} );
4346
}
4447

@@ -84,6 +87,18 @@ public void testConvertedAttributeTuple(SessionFactoryScope scope) {
8487
} );
8588
}
8689

90+
@Test
91+
public void testEnumeratedAttributeTuple(SessionFactoryScope scope) {
92+
scope.inTransaction( session -> {
93+
final TestEntity result = session.createQuery(
94+
"select t from TestEntity t where (t.id, t.status) in " +
95+
"(select t2.id, t2.status from TestEntity t2)",
96+
TestEntity.class
97+
).getSingleResult();
98+
assertThat( result.getStatus() ).isEqualTo( Status.VALID );
99+
} );
100+
}
101+
87102
@Entity( name = "TestEntity" )
88103
public static class TestEntity {
89104
@Id
@@ -92,17 +107,29 @@ public static class TestEntity {
92107
@Convert( converter = MoneyConverter.class )
93108
private Money money;
94109

110+
@Enumerated( EnumType.STRING )
111+
private Status status;
112+
95113
public TestEntity() {
96114
}
97115

98-
public TestEntity(Long id, Money money) {
116+
public TestEntity(Long id, Money money, Status status) {
99117
this.id = id;
100118
this.money = money;
119+
this.status = status;
101120
}
102121

103122
public Money getMoney() {
104123
return money;
105124
}
125+
126+
public Status getStatus() {
127+
return status;
128+
}
129+
}
130+
131+
public enum Status {
132+
VALID, INVALID
106133
}
107134

108135
public static class Money {

0 commit comments

Comments
 (0)