Skip to content

Commit

Permalink
Use implicit join to create Predicate if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
quaff committed Feb 19, 2024
1 parent fc8092d commit 9934774
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
* @author Moritz Becker
* @author Andrey Kovalev
* @author Greg Turnquist
* @author Yanming Zhou
*/
public class JpaQueryCreator extends AbstractQueryCreator<CriteriaQuery<? extends Object>, Predicate> {

Expand Down Expand Up @@ -384,6 +385,19 @@ private Expression<? extends Comparable> getComparablePath(Root<?> root, Part pa
}

private <T> Expression<T> getTypedPath(Root<?> root, Part part) {

// use implicit join if possible
Path<?> path = root;
PropertyPath property = part.getProperty();
while (!property.isCollection()) {
path = path.get(property.getSegment());
if (property.hasNext()) {
property = property.next();
} else {
return (Expression<T>) path;
}
}

return toExpressionRecursively(root, part.getProperty());
}

Expand Down

0 comments on commit 9934774

Please sign in to comment.