Skip to content

Commit dc2c282

Browse files
mbelladebeikov
authored andcommitted
HHH-17492 Add test for issue
1 parent 8daa7ce commit dc2c282

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/MultiValuedParameterTest.java

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
package org.hibernate.orm.test.query.hql;
88

9+
import java.math.BigInteger;
910
import java.time.LocalDate;
1011
import java.util.ArrayList;
1112
import java.util.Collection;
@@ -14,27 +15,30 @@
1415
import org.hibernate.boot.MetadataSources;
1516
import org.hibernate.query.Query;
1617

17-
import org.hibernate.testing.TestForIssue;
1818
import org.hibernate.testing.orm.domain.contacts.Contact;
1919
import org.hibernate.testing.orm.domain.contacts.ContactsDomainModel;
2020
import org.hibernate.testing.orm.junit.BaseSessionFactoryFunctionalTest;
21+
import org.hibernate.testing.orm.junit.Jira;
2122
import org.junit.jupiter.api.AfterAll;
2223
import org.junit.jupiter.api.BeforeAll;
2324
import org.junit.jupiter.api.Test;
2425

26+
import jakarta.persistence.Entity;
27+
import jakarta.persistence.Id;
28+
2529
import static org.hamcrest.CoreMatchers.is;
2630
import static org.junit.Assert.assertThat;
2731

2832
/**
2933
* @author Andrea Boriero
3034
*/
31-
@TestForIssue(jiraKey = "HHH-10893")
3235
public class MultiValuedParameterTest extends BaseSessionFactoryFunctionalTest {
3336

3437
@Override
3538
protected void applyMetadataSources(MetadataSources metadataSources) {
3639
super.applyMetadataSources( metadataSources );
3740
ContactsDomainModel.applyContactsModel( metadataSources );
41+
metadataSources.addAnnotatedClass( EntityWithNumericId.class );
3842
}
3943

4044
@BeforeAll
@@ -48,13 +52,17 @@ public void prepareData() {
4852
Contact.Gender.MALE,
4953
LocalDate.now()
5054
);
51-
session.save( p1 );
55+
session.persist( p1 );
56+
if ( i < 3 ) {
57+
session.persist( new EntityWithNumericId( BigInteger.valueOf( i ) ) );
58+
}
5259
}
5360
}
5461
);
5562
}
5663

5764
@Test
65+
@Jira( "https://hibernate.atlassian.net/browse/HHH-10893" )
5866
public void testParameterListIn() {
5967
inTransaction(
6068
session -> {
@@ -80,8 +88,38 @@ public void testParameterListIn() {
8088
);
8189
}
8290

91+
@Test
92+
@Jira( "https://hibernate.atlassian.net/browse/HHH-17492" )
93+
public void test() {
94+
inTransaction( session -> {
95+
final List<BigInteger> ids = List.of( BigInteger.ZERO, BigInteger.ONE, BigInteger.TWO );
96+
final List<EntityWithNumericId> resultList = session.createQuery(
97+
"select id from EntityWithNumericId e WHERE e.id in (:ids)",
98+
EntityWithNumericId.class
99+
).setParameter( "ids", ids ).getResultList();
100+
assertThat( resultList.size(), is( 3 ) );
101+
assertThat( resultList, is( ids ) );
102+
} );
103+
}
104+
83105
@AfterAll
84106
public void cleanupData() {
85-
inTransaction( session -> session.createQuery( "delete Contact" ).executeUpdate() );
107+
inTransaction( session -> {
108+
session.createMutationQuery( "delete Contact" ).executeUpdate();
109+
session.createMutationQuery( "delete EntityWithNumericId" ).executeUpdate();
110+
} );
111+
}
112+
113+
@Entity( name = "EntityWithNumericId" )
114+
public static class EntityWithNumericId {
115+
@Id
116+
private BigInteger id;
117+
118+
public EntityWithNumericId() {
119+
}
120+
121+
public EntityWithNumericId(BigInteger id) {
122+
this.id = id;
123+
}
86124
}
87125
}

0 commit comments

Comments
 (0)