Skip to content

Commit 497d714

Browse files
mbelladebeikov
authored andcommitted
HHH-18872 Resolve concrete entity name when initializing lazy to-ones
1 parent 38e15d4 commit 497d714

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

hibernate-core/src/main/java/org/hibernate/type/EntityType.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,8 +731,13 @@ protected final Object resolveIdentifier(Object id, SharedSessionContractImpleme
731731
getAssociatedEntityPersister( session.getFactory() )
732732
.isInstrumented();
733733

734-
final Object proxyOrEntity =
735-
session.internalLoad( getAssociatedEntityName(), id, isEager( overridingEager ), isNullable() );
734+
final boolean isEager = isEager( overridingEager );
735+
// If the association is lazy, retrieve the concrete type if required
736+
final String entityName = isEager ? getAssociatedEntityName()
737+
: getAssociatedEntityPersister( session.getFactory() ).resolveConcreteProxyTypeForId( id, session )
738+
.getEntityName();
739+
740+
final Object proxyOrEntity = session.internalLoad( entityName, id, isEager, isNullable() );
736741

737742
final LazyInitializer lazyInitializer = extractLazyInitializer( proxyOrEntity );
738743
if ( lazyInitializer != null ) {

0 commit comments

Comments
 (0)