I have this JPA query method:findByZzzAndXxxOrYyy
which gives results for:findBy(ZzzAndXxx)OrYyy // "And" gets higher precedence
Can I get results for?findByZzzAnd(XxxOrYyy) // "Or" gets higher precedence
Guess I can do it with other query types (e.g. native)
but I wonder if I could just set the precedence by adding underscores or symbols or something...
If I have understood it correctly, You would be writing a query, so you would have to make sure that whatever operation you want to perform first, should be included in parenthesis to get desired result.
E.g. I have table DEMO with Demo being the entity class with fields a,b and c. So per your requirement, the query would be:
Select * from Demo d where (d.a="SOME_VALUE" or d.b= "SOME_VALUE") and d.c="SOME_VALUE"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With