HHH-15632 Avoid unnecessary PersistenceContext#getEntity call in AbstractEntityInitializer

This commit is contained in:
Christian Beikov 2022-10-26 13:59:37 +02:00
parent a6441e4da2
commit 0561839140
1 changed files with 3 additions and 2 deletions

View File

@ -32,6 +32,7 @@ import org.hibernate.event.service.spi.EventListenerGroup;
import org.hibernate.event.spi.EventSource;
import org.hibernate.event.spi.PreLoadEvent;
import org.hibernate.event.spi.PreLoadEventListener;
import org.hibernate.internal.util.NullnessHelper;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.loader.entity.CacheEntityLoaderHelper;
import org.hibernate.metamodel.mapping.AttributeMapping;
@ -677,8 +678,8 @@ public abstract class AbstractEntityInitializer extends AbstractFetchParentAcces
}
}
final Object entity = persistenceContext.getEntity( entityKey );
assert entity == null || entity == toInitialize;
// Only call PersistenceContext#getEntity within the assert expression, as it is costly
assert NullnessHelper.coalesce( persistenceContext.getEntity( entityKey ), toInitialize ) == toInitialize;
final Object entityIdentifier = entityKey.getIdentifier();