Skip to content

Commit 1713a09

Browse files
committed
HHH-19294 NodeBuilder collection*() doesn't work with enum collections
1 parent 3d9829f commit 1713a09

17 files changed

+71
-17
lines changed

Diff for: hibernate-core/src/test/java/org/hibernate/orm/test/function/array/ArrayAppendTest.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ public void testNodeBuilderCollection(SessionFactoryScope scope) {
115115
cq.multiselect(
116116
root.get( "id" ),
117117
cb.collectionAppend( root.<Collection<String>>get( "theCollection" ), cb.literal( "xyz" ) ),
118-
cb.collectionAppend( root.get( "theCollection" ), "xyz" )
118+
cb.collectionAppend( root.get( "theCollection" ), "xyz" ),
119+
cb.collectionAppend( root.<Collection<Label>>get( "theLabels" ), cb.literal( Label.A ) ),
120+
cb.collectionAppend( root.get( "theLabels" ), Label.A )
119121
);
120122
em.createQuery( cq ).getResultList();
121123

Diff for: hibernate-core/src/test/java/org/hibernate/orm/test/function/array/ArrayConcatTest.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,10 @@ public void testNodeBuilderCollection(SessionFactoryScope scope) {
201201
root.get( "id" ),
202202
cb.collectionConcat( root.get( "theCollection" ), cb.collectionLiteral( "xyz" ) ),
203203
cb.collectionConcat( root.get( "theCollection" ), List.of( "xyz" ) ),
204-
cb.collectionConcat( List.of( "xyz" ), root.get( "theCollection" ) )
204+
cb.collectionConcat( List.of( "xyz" ), root.get( "theCollection" ) ),
205+
cb.collectionConcat( root.get( "theLabels" ), cb.collectionLiteral( Label.A ) ),
206+
cb.collectionConcat( root.get( "theLabels" ), List.of( Label.A ) ),
207+
cb.collectionConcat( List.of( Label.A ), root.get( "theLabels" ) )
205208
);
206209
em.createQuery( cq ).getResultList();
207210

Diff for: hibernate-core/src/test/java/org/hibernate/orm/test/function/array/ArrayContainsTest.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,13 @@ public void testNodeBuilderCollection(SessionFactoryScope scope) {
117117
cb.collectionContains( List.of( "abc", "xyz" ), cb.literal( "xyz" ) ),
118118
cb.collectionContainsNullable( root.<Collection<String>>get( "theCollection" ), cb.literal( "xyz" ) ),
119119
cb.collectionContainsNullable( root.get( "theCollection" ), "xyz" ),
120-
cb.collectionContainsNullable( List.of( "abc", "xyz" ), cb.literal( "xyz" ) )
120+
cb.collectionContainsNullable( List.of( "abc", "xyz" ), cb.literal( "xyz" ) ),
121+
cb.collectionContains( root.<Collection<Label>>get( "theLabels" ), cb.literal( Label.A ) ),
122+
cb.collectionContains( root.get( "theLabels" ), Label.A ),
123+
cb.collectionContains( List.of( Label.A, Label.B ), cb.literal( Label.A ) ),
124+
cb.collectionContainsNullable( root.<Collection<Label>>get( "theLabels" ), cb.literal( Label.A ) ),
125+
cb.collectionContainsNullable( root.get( "theLabels" ), Label.A ),
126+
cb.collectionContainsNullable( List.of( Label.A, Label.B ), cb.literal( Label.A ) )
121127
);
122128
em.createQuery( cq ).getResultList();
123129

Diff for: hibernate-core/src/test/java/org/hibernate/orm/test/function/array/ArrayGetTest.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ public void testNodeBuilderCollection(SessionFactoryScope scope) {
107107
cq.multiselect(
108108
root.get( "id" ),
109109
cb.collectionGet( root.get( "theCollection" ), cb.literal( 1 ) ),
110-
cb.collectionGet( root.get( "theCollection" ), 1 )
110+
cb.collectionGet( root.get( "theCollection" ), 1 ),
111+
cb.collectionGet( root.get( "theLabels" ), cb.literal( 1 ) ),
112+
cb.collectionGet( root.get( "theLabels" ), 1 )
111113
);
112114
em.createQuery( cq ).getResultList();
113115
} );

Diff for: hibernate-core/src/test/java/org/hibernate/orm/test/function/array/ArrayIncludesTest.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,13 @@ public void testNodeBuilderCollection(SessionFactoryScope scope) {
170170
cb.collectionIncludes( List.of( "abc", "xyz" ), cb.collectionLiteral( "xyz" ) ),
171171
cb.collectionIncludesNullable( root.<Collection<String>>get( "theCollection" ), cb.collectionLiteral( "xyz" ) ),
172172
cb.collectionIncludesNullable( root.get( "theCollection" ), List.of( "xyz" ) ),
173-
cb.collectionIncludesNullable( List.of( "abc", "xyz" ), cb.collectionLiteral( "xyz" ) )
173+
cb.collectionIncludesNullable( List.of( "abc", "xyz" ), cb.collectionLiteral( "xyz" ) ),
174+
cb.collectionIncludes( root.<Collection<Label>>get( "theLabels" ), cb.collectionLiteral( Label.A ) ),
175+
cb.collectionIncludes( root.get( "theLabels" ), List.of( Label.A ) ),
176+
cb.collectionIncludes( List.of( Label.A, Label.B ), cb.collectionLiteral( Label.A ) ),
177+
cb.collectionIncludesNullable( root.<Collection<Label>>get( "theLabels" ), cb.collectionLiteral( Label.A ) ),
178+
cb.collectionIncludesNullable( root.get( "theLabels" ), List.of( Label.A ) ),
179+
cb.collectionIncludesNullable( List.of( Label.A, Label.B ), cb.collectionLiteral( Label.A ) )
174180
);
175181
em.createQuery( cq ).getResultList();
176182

Diff for: hibernate-core/src/test/java/org/hibernate/orm/test/function/array/ArrayIntersectsTest.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,13 @@ public void testNodeBuilderCollection(SessionFactoryScope scope) {
148148
cb.collectionIntersects( List.of( "abc", "xyz" ), cb.collectionLiteral( "xyz" ) ),
149149
cb.collectionIntersectsNullable( root.<Collection<String>>get( "theCollection" ), cb.collectionLiteral( "xyz" ) ),
150150
cb.collectionIntersectsNullable( root.get( "theCollection" ), List.of( "xyz" ) ),
151-
cb.collectionIntersectsNullable( List.of( "abc", "xyz" ), cb.collectionLiteral( "xyz" ) )
151+
cb.collectionIntersectsNullable( List.of( "abc", "xyz" ), cb.collectionLiteral( "xyz" ) ),
152+
cb.collectionIntersects( root.<Collection<Label>>get( "theLabels" ), cb.collectionLiteral( Label.A ) ),
153+
cb.collectionIntersects( root.get( "theLabels" ), List.of( Label.A ) ),
154+
cb.collectionIntersects( List.of( Label.A, Label.B ), cb.collectionLiteral( Label.A ) ),
155+
cb.collectionIntersectsNullable( root.<Collection<Label>>get( "theLabels" ), cb.collectionLiteral( Label.A ) ),
156+
cb.collectionIntersectsNullable( root.get( "theLabels" ), List.of( Label.A ) ),
157+
cb.collectionIntersectsNullable( List.of( Label.A, Label.B ), cb.collectionLiteral( Label.A ) )
152158
);
153159
em.createQuery( cq ).getResultList();
154160

Diff for: hibernate-core/src/test/java/org/hibernate/orm/test/function/array/ArrayLengthTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ public void testNodeBuilderCollection(SessionFactoryScope scope) {
106106
final JpaRoot<EntityWithArrays> root = cq.from( EntityWithArrays.class );
107107
cq.multiselect(
108108
root.get( "id" ),
109-
cb.collectionLength( root.get( "theCollection" ) )
109+
cb.collectionLength( root.get( "theCollection" ) ),
110+
cb.collectionLength( root.get( "theLabels" ) )
110111
);
111112
em.createQuery( cq ).getResultList();
112113
} );

Diff for: hibernate-core/src/test/java/org/hibernate/orm/test/function/array/ArrayPositionTest.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ public void testNodeBuilderCollection(SessionFactoryScope scope) {
122122
cq.multiselect(
123123
root.get( "id" ),
124124
cb.collectionPosition( root.<Collection<String>>get( "theCollection" ), cb.literal( "xyz" ) ),
125-
cb.collectionPosition( root.get( "theCollection" ), "xyz" )
125+
cb.collectionPosition( root.get( "theCollection" ), "xyz" ),
126+
cb.collectionPosition( root.<Collection<String>>get( "theLabels" ), cb.literal( Label.A ) ),
127+
cb.collectionPosition( root.get( "theLabels" ), Label.A )
126128
);
127129
em.createQuery( cq ).getResultList();
128130

Diff for: hibernate-core/src/test/java/org/hibernate/orm/test/function/array/ArrayPositionsTest.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,11 @@ public void testNodeBuilderCollection(SessionFactoryScope scope) {
139139
cb.collectionPositions( root.<Collection<String>>get( "theCollection" ), cb.literal( "xyz" ) ),
140140
cb.collectionPositions( root.get( "theCollection" ), "xyz" ),
141141
cb.collectionPositionsList( root.<Collection<String>>get( "theCollection" ), cb.literal( "xyz" ) ),
142-
cb.collectionPositionsList( root.get( "theCollection" ), "xyz" )
142+
cb.collectionPositionsList( root.get( "theCollection" ), "xyz" ),
143+
cb.collectionPositions( root.<Collection<Label>>get( "theLabels" ), cb.literal( Label.A ) ),
144+
cb.collectionPositions( root.get( "theLabels" ), Label.A ),
145+
cb.collectionPositionsList( root.<Collection<Label>>get( "theLabels" ), cb.literal( Label.A ) ),
146+
cb.collectionPositionsList( root.get( "theLabels" ), Label.A )
143147
);
144148
em.createQuery( cq ).getResultList();
145149

Diff for: hibernate-core/src/test/java/org/hibernate/orm/test/function/array/ArrayPrependTest.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ public void testNodeBuilderCollection(SessionFactoryScope scope) {
115115
cq.multiselect(
116116
root.get( "id" ),
117117
cb.collectionPrepend( cb.literal( "xyz" ), root.<Collection<String>>get( "theCollection" ) ),
118-
cb.collectionPrepend( "xyz", root.get( "theCollection" ) )
118+
cb.collectionPrepend( "xyz", root.get( "theCollection" ) ),
119+
cb.collectionPrepend( cb.literal( Label.A ), root.<Collection<Label>>get( "theLabels" ) ),
120+
cb.collectionPrepend( "xyz", root.get( "theLabels" ) )
119121
);
120122
em.createQuery( cq ).getResultList();
121123

Diff for: hibernate-core/src/test/java/org/hibernate/orm/test/function/array/ArrayRemoveIndexTest.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ public void testNodeBuilderCollection(SessionFactoryScope scope) {
126126
cq.multiselect(
127127
root.get( "id" ),
128128
cb.collectionRemoveIndex( root.<Collection<String>>get( "theCollection" ), cb.literal( 1 ) ),
129-
cb.collectionRemoveIndex( root.get( "theCollection" ), 1 )
129+
cb.collectionRemoveIndex( root.get( "theCollection" ), 1 ),
130+
cb.collectionRemoveIndex( root.<Collection<Label>>get( "theLabels" ), cb.literal( 1 ) ),
131+
cb.collectionRemoveIndex( root.get( "theLabels" ), 1 )
130132
);
131133
em.createQuery( cq ).getResultList();
132134
} );

Diff for: hibernate-core/src/test/java/org/hibernate/orm/test/function/array/ArrayRemoveTest.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ public void testNodeBuilderCollection(SessionFactoryScope scope) {
130130
cq.multiselect(
131131
root.get( "id" ),
132132
cb.collectionRemove( root.<Collection<String>>get( "theCollection" ), cb.literal( "xyz" ) ),
133-
cb.collectionRemove( root.get( "theCollection" ), "xyz" )
133+
cb.collectionRemove( root.get( "theCollection" ), "xyz" ),
134+
cb.collectionRemove( root.<Collection<Label>>get( "theLabels" ), cb.literal( Label.A ) ),
135+
cb.collectionRemove( root.get( "theLabels" ), Label.A )
134136
);
135137
em.createQuery( cq ).getResultList();
136138

Diff for: hibernate-core/src/test/java/org/hibernate/orm/test/function/array/ArrayReplaceTest.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ public void testNodeBuilderCollection(SessionFactoryScope scope) {
136136
cb.collectionReplace( root.<Collection<String>>get( "theCollection" ), cb.literal( "abc" ), cb.literal( "xyz" ) ),
137137
cb.collectionReplace( root.<Collection<String>>get( "theCollection" ), cb.literal( "abc" ), "xyz" ),
138138
cb.collectionReplace( root.<Collection<String>>get( "theCollection" ), "abc", cb.literal( "xyz" ) ),
139-
cb.collectionReplace( root.get( "theCollection" ), "abc", "xyz" )
139+
cb.collectionReplace( root.get( "theCollection" ), "abc", "xyz" ),
140+
cb.collectionReplace( root.<Collection<Label>>get( "theLabels" ), cb.literal( Label.A ), cb.literal( Label.B ) ),
141+
cb.collectionReplace( root.<Collection<Label>>get( "theLabels" ), cb.literal( Label.A ), Label.B ),
142+
cb.collectionReplace( root.<Collection<Label>>get( "theLabels" ), Label.A, cb.literal( Label.B ) ),
143+
cb.collectionReplace( root.get( "theLabels" ), Label.A, Label.B )
140144
);
141145
em.createQuery( cq ).getResultList();
142146

Diff for: hibernate-core/src/test/java/org/hibernate/orm/test/function/array/ArraySetTest.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,11 @@ public void testNodeBuilderCollection(SessionFactoryScope scope) {
135135
cb.collectionSet( root.<Collection<String>>get( "theCollection" ), cb.literal( 1 ), cb.literal( "xyz" ) ),
136136
cb.collectionSet( root.get( "theCollection" ), cb.literal( 1 ), "xyz" ),
137137
cb.collectionSet( root.<Collection<String>>get( "theCollection" ), 1, cb.literal( "xyz" ) ),
138-
cb.collectionSet( root.get( "theCollection" ), 1, "xyz" )
138+
cb.collectionSet( root.get( "theCollection" ), 1, "xyz" ),
139+
cb.collectionSet( root.<Collection<Label>>get( "theLabels" ), cb.literal( 1 ), cb.literal( Label.A ) ),
140+
cb.collectionSet( root.get( "theLabels" ), cb.literal( 1 ), Label.A ),
141+
cb.collectionSet( root.<Collection<Label>>get( "theLabels" ), 1, cb.literal( Label.A ) ),
142+
cb.collectionSet( root.get( "theLabels" ), 1, Label.A )
139143
);
140144
em.createQuery( cq ).getResultList();
141145

Diff for: hibernate-core/src/test/java/org/hibernate/orm/test/function/array/ArraySliceTest.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ public void testNodeBuilderCollection(SessionFactoryScope scope) {
132132
cb.collectionSlice( root.get( "theCollection" ), cb.literal( 1 ), cb.literal( 1 ) ),
133133
cb.collectionSlice( root.get( "theCollection" ), cb.literal( 1 ), 1 ),
134134
cb.collectionSlice( root.get( "theCollection" ), 1, cb.literal( 1 ) ),
135-
cb.collectionSlice( root.get( "theCollection" ), 1, 1 )
135+
cb.collectionSlice( root.get( "theCollection" ), 1, 1 ),
136+
cb.collectionSlice( root.get( "theLabels" ), cb.literal( 1 ), cb.literal( 1 ) ),
137+
cb.collectionSlice( root.get( "theLabels" ), cb.literal( 1 ), 1 ),
138+
cb.collectionSlice( root.get( "theLabels" ), 1, cb.literal( 1 ) ),
139+
cb.collectionSlice( root.get( "theLabels" ), 1, 1 )
136140
);
137141
em.createQuery( cq ).getResultList();
138142
} );

Diff for: hibernate-core/src/test/java/org/hibernate/orm/test/function/array/ArrayToStringTest.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ public void testNodeBuilderCollection(SessionFactoryScope scope) {
107107
cq.multiselect(
108108
root.get( "id" ),
109109
cb.collectionToString( root.get( "theCollection" ), cb.literal( "," ) ),
110-
cb.collectionToString( root.get( "theCollection" ), "," )
110+
cb.collectionToString( root.get( "theCollection" ), "," ),
111+
cb.collectionToString( root.get( "theLabels" ), cb.literal( "," ) ),
112+
cb.collectionToString( root.get( "theLabels" ), "," )
111113
);
112114
em.createQuery( cq ).getResultList();
113115
} );

Diff for: hibernate-core/src/test/java/org/hibernate/orm/test/function/array/ArrayTrimTest.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ public void testNodeBuilderCollection(SessionFactoryScope scope) {
127127
cq.multiselect(
128128
root.get( "id" ),
129129
cb.collectionTrim( root.<Collection<String>>get( "theCollection" ), cb.literal( 1 ) ),
130-
cb.collectionTrim( root.get( "theCollection" ), 1 )
130+
cb.collectionTrim( root.get( "theCollection" ), 1 ),
131+
cb.collectionTrim( root.<Collection<Label>>get( "theLabels" ), cb.literal( 1 ) ),
132+
cb.collectionTrim( root.get( "theLabels" ), 1 )
131133
);
132134
em.createQuery( cq ).getResultList();
133135
} );

0 commit comments

Comments
 (0)