Consider Specification order in composition.
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 commit is contained in:
@@ -30,6 +30,7 @@ import org.springframework.lang.Nullable;
|
||||
* @author Sebastian Staudt
|
||||
* @author Oliver Gierke
|
||||
* @author Jens Schauder
|
||||
* @author Mark Paluch
|
||||
* @see Specification
|
||||
* @since 2.2
|
||||
*/
|
||||
@@ -44,8 +45,8 @@ class SpecificationComposition {
|
||||
|
||||
return (root, query, builder) -> {
|
||||
|
||||
Predicate otherPredicate = toPredicate(lhs, root, query, builder);
|
||||
Predicate thisPredicate = toPredicate(rhs, root, query, builder);
|
||||
Predicate thisPredicate = toPredicate(lhs, root, query, builder);
|
||||
Predicate otherPredicate = toPredicate(rhs, root, query, builder);
|
||||
|
||||
if (thisPredicate == null) {
|
||||
return otherPredicate;
|
||||
|
||||
Reference in New Issue
Block a user