diff --git a/src/main/java/org/springframework/data/jpa/repository/query/QueryUtils.java b/src/main/java/org/springframework/data/jpa/repository/query/QueryUtils.java index e24a871ceb..d94a1c4580 100644 --- a/src/main/java/org/springframework/data/jpa/repository/query/QueryUtils.java +++ b/src/main/java/org/springframework/data/jpa/repository/query/QueryUtils.java @@ -74,6 +74,7 @@ * @author Andriy Redko * @author Peter Großmann * @author Greg Turnquist + * @author Anton Molganov */ public abstract class QueryUtils { @@ -775,6 +776,16 @@ private static T getAnnotationProperty(Attribute attribute, String pro return join; } } + + for (Fetch fetch : from.getFetches()) { + + Join join = (Join) fetch; + if (joinType == join.getJoinType() + && join.getAttribute().getName().equals(attribute)) { + return join; + } + } + return from.join(attribute, joinType); }