-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
SpecificationComposition reversed predicates #2146
Comments
Does this matter? The order of execution is determined by the execution plan created by the database, not by the order of statements in the SQL statement, isn't it? |
The issue affects also |
We now consider the ordering of left-hand-side and right-hand-side arguments when composing specifications. The primary aspect is consistency so that predicates appear in the actual SQL query in the order they were combined. Most SQL databases tend to reorder the criteria according to the most useful query execution plan. Only special cases tend to follow deferred evaluation when using OR combination. Resolves #2146.
We now consider the ordering of left-hand-side and right-hand-side arguments when composing specifications. The primary aspect is consistency so that predicates appear in the actual SQL query in the order they were combined. Most SQL databases tend to reorder the criteria according to the most useful query execution plan. Only special cases tend to follow deferred evaluation when using OR combination. Resolves #2146.
This also fixes #1309. It's not really a fix though, cause if you compose two specifications in the wrong order, let's say you add a condition |
It appears that
lhs
andrhs
were reversed in 25924d8.https://github.com/spring-projects/spring-data-jpa/blob/master/src/main/java/org/springframework/data/jpa/domain/SpecificationComposition.java#L54
This causes
spec1.and(spec2)
to result inspec2 and spec1
.The text was updated successfully, but these errors were encountered: