From 36fc27dd4ad9aa68d8a8f93af76b88522bd4354f Mon Sep 17 00:00:00 2001 From: Marco Belladelli Date: Fri, 4 Aug 2023 10:24:40 +0200 Subject: [PATCH] HHH-16919 Always skip initialization for non-owning entity initializers --- .../results/graph/entity/AbstractEntityInitializer.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractEntityInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractEntityInitializer.java index 55ee29d632..97ecc18fc0 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractEntityInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractEntityInitializer.java @@ -1048,6 +1048,9 @@ public abstract class AbstractEntityInitializer extends AbstractFetchParentAcces } protected boolean skipInitialization(Object toInitialize, RowProcessingState rowProcessingState) { + if ( !isOwningInitializer ) { + return true; + } final EntityEntry entry = rowProcessingState.getSession().getPersistenceContextInternal().getEntry( toInitialize ); if ( entry == null ) { @@ -1057,7 +1060,7 @@ public abstract class AbstractEntityInitializer extends AbstractFetchParentAcces else if ( entry.getStatus().isDeletedOrGone() ) { return true; } - else if ( isOwningInitializer ) { + else { if ( isPersistentAttributeInterceptable( toInitialize ) ) { final PersistentAttributeInterceptor interceptor = asPersistentAttributeInterceptable( toInitialize ).$$_hibernate_getInterceptor(); @@ -1081,9 +1084,6 @@ public abstract class AbstractEntityInitializer extends AbstractFetchParentAcces return false; } } - else { - return true; - } } private boolean isReadOnly(RowProcessingState rowProcessingState, SharedSessionContractImplementor persistenceContext) {