Home > Back-end >  Spring JPA or when using dynamic query and combination with the generated SQL is not correct
Spring JPA or when using dynamic query and combination with the generated SQL is not correct

Time:01-27

This is my JAVA code
 list. Add (criteriaBuilder. Or (
CriteriaBuilder. And (criteriaBuilder. Equal (root) get (" a "), 1), criteriaBuilder. Equal (root) get (" b "), 1)),
CriteriaBuilder. And (criteriaBuilder. Equal (root) get (" a "), 0), criteriaBuilder. Equal (root) get (" b "), 0))
));

Execute the following JPA after generating SQL
=1 a and b=1 or 2 and a=b=2 


I want to be like this SQL what to write? Can query and enclosed
 ((a=1 and b=1) or (a=2 and b=2)) 

CodePudding user response:

To solve, the original poster
  • Related