In Spring JPA data, how can I set the priority of a property expression?

I have this JPA request method:
findByZzzAndXxxOrYyy

which gives results for:
findBy(ZzzAndXxx)OrYyy // "And" gets higher precedence

Can i get the results?
findByZzzAnd(XxxOrYyy) // "Or" gets higher precedence

Guess that I can do this with other types of queries (e.g. native)
but I'm wondering if I can just set the priority by adding underscores or characters or something else ...

+5
source share
1 answer

If I understood correctly, you would write a request, so you would need to make sure that any operation that you want to perform in the first place should be included in parentheses to obtain the desired result.

eg. I have a DEMO table with Demo, which is an entity class with fields a, b, and c. Thus, according to your requirement, the request will look like this:

Select * from Demo d where (da = "SOME_VALUE" or db = "SOME_VALUE") and dc = "SOME_VALUE"

+1
source

Source: https://habr.com/ru/post/1236629/


All Articles