Skip to content

Commit 1d1be82

Browse files
committed
Added query fetches search for join existence when applying JPA ordering.
Closes spring-projects#2253 See spring-projects#2253
1 parent 7cbfad9 commit 1d1be82

File tree

1 file changed

+11
-0
lines changed
  • spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query

1 file changed

+11
-0
lines changed

Diff for: spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/QueryUtils.java

+11
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
* @author Greg Turnquist
7777
* @author Diego Krupitza
7878
* @author Jędrzej Biedrzycki
79+
* @author Anton Molganov
7980
*/
8081
public abstract class QueryUtils {
8182

@@ -806,6 +807,16 @@ private static <T> T getAnnotationProperty(Attribute<?, ?> attribute, String pro
806807
return join;
807808
}
808809
}
810+
811+
for (Fetch<?, ?> fetch : from.getFetches()) {
812+
813+
Join<?, ?> join = (Join<?, ?>) fetch;
814+
if (joinType == join.getJoinType()
815+
&& join.getAttribute().getName().equals(attribute)) {
816+
return join;
817+
}
818+
}
819+
809820
return from.join(attribute, joinType);
810821
}
811822

0 commit comments

Comments
 (0)