Avoid EntityFetchJoinedImpl visiting the EntityIdentifierMapping

This commit is contained in:
Andrea Boriero 2020-01-31 09:57:40 +00:00
parent bd28b54482
commit 2afd4c8123
2 changed files with 17 additions and 8 deletions

View File

@ -12,6 +12,7 @@ import org.hibernate.LockMode;
import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.EntityValuedModelPart; import org.hibernate.metamodel.mapping.EntityValuedModelPart;
import org.hibernate.query.NavigablePath; 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.AssemblerCreationState;
import org.hibernate.sql.results.graph.DomainResultAssembler; import org.hibernate.sql.results.graph.DomainResultAssembler;
import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.DomainResultCreationState;
@ -26,18 +27,18 @@ import org.hibernate.sql.results.graph.entity.internal.EntityAssembler;
* *
* @author Andrea Boriero * @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 FetchParent fetchParent;
private final boolean nullable; private final boolean nullable;
private final EntityValuedModelPart referencedModelPart;
public AbstractNonLazyEntityFetch( public AbstractNonLazyEntityFetch(
FetchParent fetchParent, FetchParent fetchParent,
EntityValuedModelPart fetchedPart, EntityValuedModelPart fetchedPart,
NavigablePath navigablePath, NavigablePath navigablePath,
boolean nullable, boolean nullable) {
LockMode lockMode, super( fetchedPart.getEntityMappingType(), navigablePath );
DomainResultCreationState creationState) { this.referencedModelPart = fetchedPart;
super( fetchedPart, lockMode, navigablePath, creationState );
this.fetchParent = fetchParent; this.fetchParent = fetchParent;
this.nullable = nullable; this.nullable = nullable;
} }
@ -85,4 +86,9 @@ public abstract class AbstractNonLazyEntityFetch extends AbstractEntityResultGra
FetchParentAccess parentAccess, FetchParentAccess parentAccess,
Consumer<Initializer> collector, Consumer<Initializer> collector,
AssemblerCreationState creationState); AssemblerCreationState creationState);
@Override
public EntityValuedModelPart getEntityValuedModelPart() {
return referencedModelPart;
}
} }

View File

@ -10,6 +10,7 @@ import java.util.function.Consumer;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.engine.FetchTiming; 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.AbstractNonLazyEntityFetch;
import org.hibernate.sql.results.graph.entity.EntityInitializer; import org.hibernate.sql.results.graph.entity.EntityInitializer;
import org.hibernate.sql.results.graph.entity.EntityValuedFetchable; import org.hibernate.sql.results.graph.entity.EntityValuedFetchable;
@ -27,6 +28,7 @@ import org.hibernate.sql.results.graph.Initializer;
public class EntityFetchJoinedImpl extends AbstractNonLazyEntityFetch { public class EntityFetchJoinedImpl extends AbstractNonLazyEntityFetch {
private final EntityResultImpl entityResult; private final EntityResultImpl entityResult;
private final LockMode lockMode;
public EntityFetchJoinedImpl( public EntityFetchJoinedImpl(
FetchParent fetchParent, FetchParent fetchParent,
@ -35,8 +37,8 @@ public class EntityFetchJoinedImpl extends AbstractNonLazyEntityFetch {
boolean nullable, boolean nullable,
NavigablePath navigablePath, NavigablePath navigablePath,
DomainResultCreationState creationState) { DomainResultCreationState creationState) {
super( fetchParent, fetchedAttribute, navigablePath, nullable, lockMode, creationState ); super( fetchParent, fetchedAttribute, navigablePath, nullable );
this.lockMode = lockMode;
entityResult = new EntityResultImpl( entityResult = new EntityResultImpl(
navigablePath, navigablePath,
fetchedAttribute, fetchedAttribute,
@ -53,7 +55,7 @@ public class EntityFetchJoinedImpl extends AbstractNonLazyEntityFetch {
return new EntityInitializerJoinedFetch( return new EntityInitializerJoinedFetch(
entityResult, entityResult,
getNavigablePath(), getNavigablePath(),
getLockMode(), lockMode,
entityResult.getIdentifierResult(), entityResult.getIdentifierResult(),
entityResult.getDiscriminatorResult(), entityResult.getDiscriminatorResult(),
entityResult.getVersionResult(), entityResult.getVersionResult(),
@ -71,4 +73,5 @@ public class EntityFetchJoinedImpl extends AbstractNonLazyEntityFetch {
public boolean hasTableGroup() { public boolean hasTableGroup() {
return true; return true;
} }
} }