diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityDelayedFetchInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityDelayedFetchInitializer.java index b4b4b8f7b4..8ab09fcbea 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityDelayedFetchInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityDelayedFetchInitializer.java @@ -8,16 +8,13 @@ package org.hibernate.sql.results.graph.entity.internal; import java.util.function.Consumer; -import org.hibernate.LockMode; import org.hibernate.NotYetImplementedFor6Exception; import org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer; import org.hibernate.engine.spi.EntityKey; import org.hibernate.engine.spi.EntityUniqueKey; import org.hibernate.engine.spi.PersistenceContext; import org.hibernate.engine.spi.SharedSessionContractImplementor; -import org.hibernate.event.spi.EventSource; import org.hibernate.internal.log.LoggingHelper; -import org.hibernate.loader.entity.CacheEntityLoaderHelper; import org.hibernate.metamodel.mapping.ModelPart; import org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping; import org.hibernate.persister.entity.EntityPersister; @@ -27,11 +24,10 @@ import org.hibernate.query.NavigablePath; import org.hibernate.sql.results.graph.AbstractFetchParentAccess; import org.hibernate.sql.results.graph.DomainResultAssembler; import org.hibernate.sql.results.graph.FetchParentAccess; +import org.hibernate.sql.results.graph.entity.AbstractEntityInitializer; import org.hibernate.sql.results.graph.entity.EntityInitializer; -import org.hibernate.sql.results.graph.entity.EntityValuedFetchable; import org.hibernate.sql.results.graph.entity.LoadingEntityEntry; import org.hibernate.sql.results.jdbc.spi.RowProcessingState; -import org.hibernate.stat.spi.StatisticsImplementor; /** * @author Andrea Boriero @@ -72,7 +68,7 @@ public class EntityDelayedFetchInitializer extends AbstractFetchParentAccess imp } @Override - public ModelPart getInitializedPart(){ + public ModelPart getInitializedPart() { return referencedModelPart; } @@ -121,6 +117,11 @@ public class EntityDelayedFetchInitializer extends AbstractFetchParentAccess imp final PersistenceContext persistenceContext = session.getPersistenceContextInternal(); entityInstance = persistenceContext.getEntity( euk ); if ( entityInstance == null ) { + if ( ((AbstractEntityInitializer) this.parentAccess).getEntityDescriptor() + .getBytecodeEnhancementMetadata() + .isEnhancedForLazyLoading() ) { + return; + } entityInstance = ( (UniqueKeyLoadable) concreteDescriptor ).loadByUniqueKey( uniqueKeyPropertyName, identifier, diff --git a/hibernate-core/src/test/java/org/hibernate/test/mapping/lazytoone/mappedby/InverseToOneAllowProxyTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/lazytoone/mappedby/InverseToOneAllowProxyTests.java similarity index 99% rename from hibernate-core/src/test/java/org/hibernate/test/mapping/lazytoone/mappedby/InverseToOneAllowProxyTests.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/mapping/lazytoone/mappedby/InverseToOneAllowProxyTests.java index a2007cfea5..d2cb4725c5 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/mapping/lazytoone/mappedby/InverseToOneAllowProxyTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/lazytoone/mappedby/InverseToOneAllowProxyTests.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.mapping.lazytoone.mappedby; +package org.hibernate.orm.test.mapping.lazytoone.mappedby; import jakarta.persistence.Entity; import jakarta.persistence.Id; diff --git a/hibernate-core/src/test/java/org/hibernate/test/mapping/lazytoone/mappedby/InverseToOneExplicitOptionTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/lazytoone/mappedby/InverseToOneExplicitOptionTests.java similarity index 99% rename from hibernate-core/src/test/java/org/hibernate/test/mapping/lazytoone/mappedby/InverseToOneExplicitOptionTests.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/mapping/lazytoone/mappedby/InverseToOneExplicitOptionTests.java index 376b2d4fb8..9b4457cf8d 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/mapping/lazytoone/mappedby/InverseToOneExplicitOptionTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/lazytoone/mappedby/InverseToOneExplicitOptionTests.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.mapping.lazytoone.mappedby; +package org.hibernate.orm.test.mapping.lazytoone.mappedby; import jakarta.persistence.Entity; import jakarta.persistence.Id;