From c88269955775b11362fd7f0c11f68b904120cf73 Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Mon, 28 Nov 2022 16:33:00 +0000 Subject: [PATCH] HHH-15776 Avoid type checking for ManagedEntity in StatefulPersistenceContext#addReferenceEntry --- .../engine/internal/StatefulPersistenceContext.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/internal/StatefulPersistenceContext.java b/hibernate-core/src/main/java/org/hibernate/engine/internal/StatefulPersistenceContext.java index 1b11d43d2c..0b31d75ac0 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/internal/StatefulPersistenceContext.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/internal/StatefulPersistenceContext.java @@ -68,6 +68,7 @@ import org.hibernate.type.CollectionType; import org.jboss.logging.Logger; +import static org.hibernate.engine.internal.ManagedTypeHelper.asManagedEntity; import static org.hibernate.engine.internal.ManagedTypeHelper.asPersistentAttributeInterceptable; import static org.hibernate.engine.internal.ManagedTypeHelper.isPersistentAttributeInterceptable; @@ -577,9 +578,9 @@ public class StatefulPersistenceContext implements PersistenceContext { public void addReferenceEntry( final Object entity, final Status status) { - - ((ManagedEntity)entity).$$_hibernate_getEntityEntry().setStatus( status ); - entityEntryContext.addEntityEntry( entity, ((ManagedEntity)entity).$$_hibernate_getEntityEntry() ); + final EntityEntry entityEntry = asManagedEntity( entity ).$$_hibernate_getEntityEntry(); + entityEntry.setStatus( status ); + entityEntryContext.addEntityEntry( entity, entityEntry ); setHasNonReadOnlyEnties( status ); }