HHH-15699 HibernateException: Found shared references to a collection when ShareCacheMode.All or ShareCacheMode.DISABLE_SELECTIVE

This commit is contained in:
Andrea Boriero 2022-11-18 01:16:32 +01:00 committed by Andrea Boriero
parent d9c790cae1
commit ff973d4580
1 changed files with 6 additions and 0 deletions

View File

@ -102,6 +102,12 @@ public class EntityDelayedFetchInitializer extends AbstractFetchParentAccess imp
if ( loadingEntityLocally != null ) { if ( loadingEntityLocally != null ) {
entityInstance = loadingEntityLocally.getEntityInstance(); entityInstance = loadingEntityLocally.getEntityInstance();
} }
if ( entityInstance == null ) {
entityInstance = persistenceContext.getEntity( entityKey );
if ( entityInstance != null ) {
entityInstance = persistenceContext.proxyFor( entityInstance );
}
}
} }
if ( entityInstance == null ) { if ( entityInstance == null ) {
if ( referencedModelPart.isOptional() && parentAccess != null && parentAccess.getInitializedPart() if ( referencedModelPart.isOptional() && parentAccess != null && parentAccess.getInitializedPart()