Skip to content

Commit d76bce7

Browse files
committed
Added query fetches search for join existence when applying JPA ordering.
Closes #2253 See #2253
1 parent d0c3b1a commit d76bce7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/main/java/org/springframework/data/jpa/repository/query/QueryUtils.java

+11
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
* @author Andriy Redko
7575
* @author Peter Großmann
7676
* @author Greg Turnquist
77+
* @author Anton Molganov
7778
*/
7879
public abstract class QueryUtils {
7980

@@ -775,6 +776,16 @@ private static <T> T getAnnotationProperty(Attribute<?, ?> attribute, String pro
775776
return join;
776777
}
777778
}
779+
780+
for (Fetch<?, ?> fetch : from.getFetches()) {
781+
782+
Join<?, ?> join = (Join<?, ?>) fetch;
783+
if (joinType == join.getJoinType()
784+
&& join.getAttribute().getName().equals(attribute)) {
785+
return join;
786+
}
787+
}
788+
778789
return from.join(attribute, joinType);
779790
}
780791

0 commit comments

Comments
 (0)