6
6
*/
7
7
package org .hibernate .orm .test .query .hql ;
8
8
9
+ import java .math .BigInteger ;
9
10
import java .time .LocalDate ;
10
11
import java .util .ArrayList ;
11
12
import java .util .Collection ;
14
15
import org .hibernate .boot .MetadataSources ;
15
16
import org .hibernate .query .Query ;
16
17
17
- import org .hibernate .testing .TestForIssue ;
18
18
import org .hibernate .testing .orm .domain .contacts .Contact ;
19
19
import org .hibernate .testing .orm .domain .contacts .ContactsDomainModel ;
20
20
import org .hibernate .testing .orm .junit .BaseSessionFactoryFunctionalTest ;
21
+ import org .hibernate .testing .orm .junit .Jira ;
21
22
import org .junit .jupiter .api .AfterAll ;
22
23
import org .junit .jupiter .api .BeforeAll ;
23
24
import org .junit .jupiter .api .Test ;
24
25
26
+ import jakarta .persistence .Entity ;
27
+ import jakarta .persistence .Id ;
28
+
25
29
import static org .hamcrest .CoreMatchers .is ;
26
30
import static org .junit .Assert .assertThat ;
27
31
28
32
/**
29
33
* @author Andrea Boriero
30
34
*/
31
- @ TestForIssue (jiraKey = "HHH-10893" )
32
35
public class MultiValuedParameterTest extends BaseSessionFactoryFunctionalTest {
33
36
34
37
@ Override
35
38
protected void applyMetadataSources (MetadataSources metadataSources ) {
36
39
super .applyMetadataSources ( metadataSources );
37
40
ContactsDomainModel .applyContactsModel ( metadataSources );
41
+ metadataSources .addAnnotatedClass ( EntityWithNumericId .class );
38
42
}
39
43
40
44
@ BeforeAll
@@ -48,13 +52,17 @@ public void prepareData() {
48
52
Contact .Gender .MALE ,
49
53
LocalDate .now ()
50
54
);
51
- session .save ( p1 );
55
+ session .persist ( p1 );
56
+ if ( i < 3 ) {
57
+ session .persist ( new EntityWithNumericId ( BigInteger .valueOf ( i ) ) );
58
+ }
52
59
}
53
60
}
54
61
);
55
62
}
56
63
57
64
@ Test
65
+ @ Jira ( "https://hibernate.atlassian.net/browse/HHH-10893" )
58
66
public void testParameterListIn () {
59
67
inTransaction (
60
68
session -> {
@@ -80,8 +88,38 @@ public void testParameterListIn() {
80
88
);
81
89
}
82
90
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
+
83
105
@ AfterAll
84
106
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
+ }
86
124
}
87
125
}
0 commit comments