diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractNonLazyEntityFetch.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractNonLazyEntityFetch.java index bd58871666..4cae2e7b3d 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractNonLazyEntityFetch.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractNonLazyEntityFetch.java @@ -12,6 +12,7 @@ import org.hibernate.LockMode; import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.EntityValuedModelPart; import org.hibernate.query.NavigablePath; +import org.hibernate.sql.results.graph.AbstractFetchParent; import org.hibernate.sql.results.graph.AssemblerCreationState; import org.hibernate.sql.results.graph.DomainResultAssembler; import org.hibernate.sql.results.graph.DomainResultCreationState; @@ -26,18 +27,18 @@ import org.hibernate.sql.results.graph.entity.internal.EntityAssembler; * * @author Andrea Boriero */ -public abstract class AbstractNonLazyEntityFetch extends AbstractEntityResultGraphNode implements EntityFetch { +public abstract class AbstractNonLazyEntityFetch extends AbstractFetchParent implements EntityFetch { private final FetchParent fetchParent; private final boolean nullable; + private final EntityValuedModelPart referencedModelPart; public AbstractNonLazyEntityFetch( FetchParent fetchParent, EntityValuedModelPart fetchedPart, NavigablePath navigablePath, - boolean nullable, - LockMode lockMode, - DomainResultCreationState creationState) { - super( fetchedPart, lockMode, navigablePath, creationState ); + boolean nullable) { + super( fetchedPart.getEntityMappingType(), navigablePath ); + this.referencedModelPart = fetchedPart; this.fetchParent = fetchParent; this.nullable = nullable; } @@ -85,4 +86,9 @@ public abstract class AbstractNonLazyEntityFetch extends AbstractEntityResultGra FetchParentAccess parentAccess, Consumer collector, AssemblerCreationState creationState); + + @Override + public EntityValuedModelPart getEntityValuedModelPart() { + return referencedModelPart; + } } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityFetchJoinedImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityFetchJoinedImpl.java index 5856350c80..c94d00fa57 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityFetchJoinedImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityFetchJoinedImpl.java @@ -10,6 +10,7 @@ import java.util.function.Consumer; import org.hibernate.LockMode; import org.hibernate.engine.FetchTiming; +import org.hibernate.metamodel.mapping.EntityValuedModelPart; import org.hibernate.sql.results.graph.entity.AbstractNonLazyEntityFetch; import org.hibernate.sql.results.graph.entity.EntityInitializer; import org.hibernate.sql.results.graph.entity.EntityValuedFetchable; @@ -27,6 +28,7 @@ import org.hibernate.sql.results.graph.Initializer; public class EntityFetchJoinedImpl extends AbstractNonLazyEntityFetch { private final EntityResultImpl entityResult; + private final LockMode lockMode; public EntityFetchJoinedImpl( FetchParent fetchParent, @@ -35,8 +37,8 @@ public class EntityFetchJoinedImpl extends AbstractNonLazyEntityFetch { boolean nullable, NavigablePath navigablePath, DomainResultCreationState creationState) { - super( fetchParent, fetchedAttribute, navigablePath, nullable, lockMode, creationState ); - + super( fetchParent, fetchedAttribute, navigablePath, nullable ); + this.lockMode = lockMode; entityResult = new EntityResultImpl( navigablePath, fetchedAttribute, @@ -53,7 +55,7 @@ public class EntityFetchJoinedImpl extends AbstractNonLazyEntityFetch { return new EntityInitializerJoinedFetch( entityResult, getNavigablePath(), - getLockMode(), + lockMode, entityResult.getIdentifierResult(), entityResult.getDiscriminatorResult(), entityResult.getVersionResult(), @@ -71,4 +73,5 @@ public class EntityFetchJoinedImpl extends AbstractNonLazyEntityFetch { public boolean hasTableGroup() { return true; } + }