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.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<Initializer> collector,
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.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;
}
}