NonLazyEntityFetch improvements

This commit is contained in:
Steve Ebersole 2022-03-03 16:04:42 -06:00
parent ec737a7f15
commit 2ced4caa2c
5 changed files with 25 additions and 28 deletions

View File

@ -467,7 +467,6 @@ public class EntityCollectionPart
fetchParent,
this,
partTableGroup,
selected,
fetchablePath,
creationState
);

View File

@ -968,7 +968,6 @@ public class ToOneAttributeMapping
fetchParent,
this,
tableGroup,
false,
fetchablePath,
creationState
);
@ -1077,7 +1076,6 @@ public class ToOneAttributeMapping
fetchParent,
this,
tableGroup,
true,
fetchablePath,
creationState
);

View File

@ -7,14 +7,12 @@
package org.hibernate.sql.results.graph.entity;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.EntityValuedModelPart;
import org.hibernate.query.spi.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.FetchParent;
import org.hibernate.sql.results.graph.FetchParentAccess;
import org.hibernate.sql.results.graph.Fetchable;
import org.hibernate.sql.results.graph.entity.internal.EntityAssembler;
/**
@ -24,23 +22,30 @@ import org.hibernate.sql.results.graph.entity.internal.EntityAssembler;
*/
public abstract class AbstractNonLazyEntityFetch extends AbstractFetchParent implements EntityFetch {
private final FetchParent fetchParent;
private final boolean nullable;
private final EntityValuedModelPart referencedModelPart;
private final EntityValuedFetchable referencedModelPart;
public AbstractNonLazyEntityFetch(
FetchParent fetchParent,
EntityValuedModelPart fetchedPart,
NavigablePath navigablePath,
boolean nullable) {
EntityValuedFetchable fetchedPart,
NavigablePath navigablePath) {
super( fetchedPart.getEntityMappingType(), navigablePath );
this.referencedModelPart = fetchedPart;
this.fetchParent = fetchParent;
this.nullable = nullable;
}
@Override
public EntityMappingType getReferencedMappingType() {
return getEntityValuedModelPart().getEntityMappingType();
public EntityValuedFetchable getEntityValuedModelPart() {
return referencedModelPart;
}
@Override
public EntityValuedFetchable getReferencedModePart() {
return getEntityValuedModelPart();
}
@Override
public EntityValuedFetchable getReferencedMappingType() {
return getEntityValuedModelPart();
}
@Override
@ -48,18 +53,18 @@ public abstract class AbstractNonLazyEntityFetch extends AbstractFetchParent imp
return getEntityValuedModelPart().getEntityMappingType();
}
@Override
public EntityValuedFetchable getFetchedMapping() {
return getEntityValuedModelPart();
}
@Override
public FetchParent getFetchParent() {
return fetchParent;
}
@Override
public Fetchable getFetchedMapping() {
return (Fetchable) getEntityValuedModelPart();
}
@Override
public DomainResultAssembler createAssembler(
public DomainResultAssembler<?> createAssembler(
FetchParentAccess parentAccess,
AssemblerCreationState creationState) {
final EntityInitializer entityInitializer = getEntityInitializer( parentAccess, creationState );
@ -69,9 +74,4 @@ public abstract class AbstractNonLazyEntityFetch extends AbstractFetchParent imp
protected abstract EntityInitializer getEntityInitializer(
FetchParentAccess parentAccess,
AssemblerCreationState creationState);
@Override
public EntityValuedModelPart getEntityValuedModelPart() {
return referencedModelPart;
}
}

View File

@ -30,10 +30,9 @@ public class EntityFetchJoinedImpl extends AbstractNonLazyEntityFetch {
FetchParent fetchParent,
EntityValuedFetchable fetchedAttribute,
TableGroup tableGroup,
boolean nullable,
NavigablePath navigablePath,
DomainResultCreationState creationState) {
super( fetchParent, fetchedAttribute, navigablePath, nullable );
super( fetchParent, fetchedAttribute, navigablePath );
this.sourceAlias = tableGroup.getSourceAlias();
this.entityResult = new EntityResultImpl(
navigablePath,
@ -51,7 +50,7 @@ public class EntityFetchJoinedImpl extends AbstractNonLazyEntityFetch {
AssemblerCreationState creationState) {
return (EntityInitializer) creationState.resolveInitializer(
getNavigablePath(),
getEntityValuedModelPart(),
getReferencedModePart(),
() -> new EntityJoinedFetchInitializer(
entityResult,
getReferencedModePart(),

View File

@ -16,6 +16,7 @@ import org.hibernate.sql.results.graph.AssemblerCreationState;
import org.hibernate.sql.results.graph.Fetch;
import org.hibernate.sql.results.graph.entity.AbstractEntityInitializer;
import org.hibernate.sql.results.graph.entity.EntityResultGraphNode;
import org.hibernate.sql.results.graph.entity.EntityValuedFetchable;
/**
* @author Andrea Boriero
@ -27,7 +28,7 @@ public class EntityJoinedFetchInitializer extends AbstractEntityInitializer {
public EntityJoinedFetchInitializer(
EntityResultGraphNode resultDescriptor,
ModelPart referencedModelPart,
EntityValuedFetchable referencedFetchable,
NavigablePath navigablePath,
LockMode lockMode,
Fetch identifierFetch,