HHH-15776 Avoid type checking for ManagedEntity in EntityEntryContext#deserialize as well

This commit is contained in:
Sanne Grinovero 2022-11-28 16:33:56 +00:00 committed by Sanne Grinovero
parent c882699557
commit e4c294f4b6
1 changed files with 4 additions and 3 deletions

View File

@ -460,16 +460,17 @@ public class EntityEntryContext {
final ManagedEntity managedEntity; final ManagedEntity managedEntity;
if ( isEnhanced ) { if ( isEnhanced ) {
if ( entry.getPersister().isMutable() ) { if ( entry.getPersister().isMutable() ) {
managedEntity = (ManagedEntity) entity; managedEntity = ManagedTypeHelper.asManagedEntity( entity );
} }
else { else {
managedEntity = new ImmutableManagedEntityHolder( (ManagedEntity) entity ); final ManagedEntity castedEntity = asManagedEntity( entity );
managedEntity = new ImmutableManagedEntityHolder( castedEntity );
if ( context.immutableManagedEntityXref == null ) { if ( context.immutableManagedEntityXref == null ) {
context.immutableManagedEntityXref = context.immutableManagedEntityXref =
new IdentityHashMap<>(); new IdentityHashMap<>();
} }
context.immutableManagedEntityXref.put( context.immutableManagedEntityXref.put(
(ManagedEntity) entity, castedEntity,
(ImmutableManagedEntityHolder) managedEntity (ImmutableManagedEntityHolder) managedEntity
); );