@@ -179,6 +179,42 @@ public void criteriaTester3() {
179
179
assertThat (result ).hasSize (1 );
180
180
}
181
181
182
+ @ Test
183
+ @ Transactional
184
+ public void criteriaTesterMultipleJoinWhereCriteria () {
185
+ CriteriaBuilder cb = entityManager .getCriteriaBuilder ();
186
+
187
+ CriteriaQuery <TaskEntity > tasksQuery = cb .createQuery (TaskEntity .class );
188
+ Root <TaskEntity > task = tasksQuery .from (TaskEntity .class );
189
+
190
+ Join <TaskEntity , TaskVariableEntity > taskVariableEntityJoin1 = task .join ("variables" );
191
+
192
+ Predicate var1 = cb .and (
193
+ cb .equal (taskVariableEntityJoin1 .get ("name" ), "variable2" ),
194
+ cb .equal (taskVariableEntityJoin1 .get ("value" ), new VariableValue <>(Boolean .TRUE ))
195
+ );
196
+
197
+ taskVariableEntityJoin1 .on (var1 );
198
+ taskVariableEntityJoin1 .alias ("var1" );
199
+
200
+ Join <TaskEntity , TaskVariableEntity > taskVariableEntityJoin2 = task .join ("variables" );
201
+ Predicate var2 = cb .and (
202
+ cb .equal (taskVariableEntityJoin2 .get ("name" ), "variable1" ),
203
+ cb .equal (taskVariableEntityJoin2 .get ("value" ), new VariableValue <>(new String ("data" )))
204
+ );
205
+
206
+ taskVariableEntityJoin2 .on (var2 );
207
+ taskVariableEntityJoin2 .alias ("var2" );
208
+
209
+ tasksQuery .select (task );
210
+ // when:
211
+ List <TaskEntity > result = entityManager .createQuery (tasksQuery ).getResultList ();
212
+
213
+ // then:
214
+ assertThat (result ).isNotEmpty ();
215
+ assertThat (result ).hasSize (1 );
216
+ }
217
+
182
218
@ Test
183
219
@ Transactional
184
220
public void criteriaTester4 () {
@@ -838,6 +874,51 @@ public void queryTasksVariablesWhereWithExplicitANDEXISTSByNameAndValueCriteria(
838
874
assertThat (result .toString ()).isEqualTo (expected );
839
875
}
840
876
877
+ @ Test
878
+ public void queryTasksVariablesWhereWithExplicitANDByMultipleNameAndValueCriteria () {
879
+ //given
880
+ String query =
881
+ "query {" +
882
+ " Tasks(where: {" +
883
+ " status: {EQ: COMPLETED}" +
884
+ " AND: [" +
885
+ " {" +
886
+ " variables: {" +
887
+ " name: {EQ: \" variable1\" }" +
888
+ " value: {EQ: \" data\" } }" +
889
+ " }" +
890
+ " {" +
891
+ " variables: {" +
892
+ " name: {EQ: \" variable2\" }" +
893
+ " value: {EQ: true} }" +
894
+ " }" +
895
+ " ]" +
896
+ " }) {" +
897
+ " select {" +
898
+ " id" +
899
+ " status" +
900
+ " variables {" +
901
+ " name" +
902
+ " value" +
903
+ " }" +
904
+ " }" +
905
+ " }" +
906
+ "}" ;
907
+
908
+ String expected =
909
+ "{Tasks={select=[" +
910
+ "{id=1, status=COMPLETED, variables=[" +
911
+ "{name=variable2, value=true}, " +
912
+ "{name=variable1, value=data}]}" +
913
+ "]}}" ;
914
+
915
+ //when
916
+ Object result = executor .execute (query ).getData ();
917
+
918
+ // then
919
+ assertThat (result .toString ()).isEqualTo (expected );
920
+ }
921
+
841
922
@ Test
842
923
public void queryTasksVariablesWhereWithEXISTSByNameAndValueCriteria () {
843
924
//given
0 commit comments