66 */
77package org .hibernate .orm .test .query .hql ;
88
9+ import java .math .BigInteger ;
910import java .time .LocalDate ;
1011import java .util .ArrayList ;
1112import java .util .Collection ;
1415import org .hibernate .boot .MetadataSources ;
1516import org .hibernate .query .Query ;
1617
17- import org .hibernate .testing .TestForIssue ;
1818import org .hibernate .testing .orm .domain .contacts .Contact ;
1919import org .hibernate .testing .orm .domain .contacts .ContactsDomainModel ;
2020import org .hibernate .testing .orm .junit .BaseSessionFactoryFunctionalTest ;
21+ import org .hibernate .testing .orm .junit .Jira ;
2122import org .junit .jupiter .api .AfterAll ;
2223import org .junit .jupiter .api .BeforeAll ;
2324import org .junit .jupiter .api .Test ;
2425
26+ import jakarta .persistence .Entity ;
27+ import jakarta .persistence .Id ;
28+
2529import static org .hamcrest .CoreMatchers .is ;
2630import static org .junit .Assert .assertThat ;
2731
2832/**
2933 * @author Andrea Boriero
3034 */
31- @ TestForIssue (jiraKey = "HHH-10893" )
3235public 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