diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityDelayedFetchInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityDelayedFetchInitializer.java index 5d79645baa..a05ec80a9f 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityDelayedFetchInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityDelayedFetchInitializer.java @@ -102,6 +102,12 @@ public class EntityDelayedFetchInitializer extends AbstractFetchParentAccess imp if ( loadingEntityLocally != null ) { entityInstance = loadingEntityLocally.getEntityInstance(); } + if ( entityInstance == null ) { + entityInstance = persistenceContext.getEntity( entityKey ); + if ( entityInstance != null ) { + entityInstance = persistenceContext.proxyFor( entityInstance ); + } + } } if ( entityInstance == null ) { if ( referencedModelPart.isOptional() && parentAccess != null && parentAccess.getInitializedPart()