-
Notifications
You must be signed in to change notification settings - Fork 348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bad SQL génération with Criteria class and complex operand #1938
Comments
The API intentionally follows a style that makes it seem like you would write some criteria to not interfere with AND and OR precedence. You can create groups of nested criteria. Have you seen our |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
Hello, thank you and sorry for this late response. It's ok, I found my problem thanks to the given test code. This following criteria : Criteria criteria = initial
.and(Criteria.where("name").is("FooA")
.or(Criteria.where("name").is("FooB"))
.or(Criteria.where("name").is("FooC"))) //
.and(Criteria.where("name").is("FooD")
); produces :
while the following criteria : Criteria criteria = Criteria.empty()
.or(Criteria.where("name").is("FooA"))
.or(Criteria.where("name").is("FooB"))
.or(Criteria.where("name").is("FooC"))
.and(Criteria.where("name").is("FooD")
); produces :
As it is not a direct usage and it's a generic code, I was doing the second one instead thinking I have the first one Thank you. |
Thanks for the feedback. |
Hello,
I am having some trouble when generating queries with the Criteria class (org.springframework.data.relational.core.query)
It's seems not possible to make a query like :
(a OR b) AND c
=> This will be generated asa OR b AND c
: it's not the same result.I have defined the following method to generate an OR's combination :
And for the AND combination :
Doing this, I'm expecting to have an OR combination inside a AND combination rounded with parenthesis in the generated query. It's not the case, when the OR combination is the first operand of the AND combination.
To solve the problem, I have to ensure the OR sub criteria is not placed at the first position of a AND criteria : it can't be used in a generic engine...
Is this API still maintained ?
Is there any workaround to permit the use of this API in any OR / AND combination ?
Thank you.
The text was updated successfully, but these errors were encountered: