HHH-17126 Improve type narrowing in signatures of AbstractFetchParent
This commit is contained in:
parent
a5251ce95b
commit
9a2803453c
|
@ -15,15 +15,13 @@ import org.hibernate.type.descriptor.java.JavaType;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public abstract class AbstractFetchParent implements FetchParent {
|
||||
private final FetchableContainer fetchContainer;
|
||||
private final NavigablePath navigablePath;
|
||||
|
||||
private ImmutableFetchList fetches = ImmutableFetchList.EMPTY;
|
||||
private boolean hasJoinFetches;
|
||||
private boolean containsCollectionFetches;
|
||||
|
||||
public AbstractFetchParent(FetchableContainer fetchContainer, NavigablePath navigablePath) {
|
||||
this.fetchContainer = fetchContainer;
|
||||
public AbstractFetchParent(NavigablePath navigablePath) {
|
||||
this.navigablePath = navigablePath;
|
||||
}
|
||||
|
||||
|
@ -38,9 +36,7 @@ public abstract class AbstractFetchParent implements FetchParent {
|
|||
this.containsCollectionFetches = newFetches.containsCollectionFetches();
|
||||
}
|
||||
|
||||
public FetchableContainer getFetchContainer() {
|
||||
return fetchContainer;
|
||||
}
|
||||
public abstract FetchableContainer getFetchContainer();
|
||||
|
||||
@Override
|
||||
public NavigablePath getNavigablePath() {
|
||||
|
@ -49,12 +45,12 @@ public abstract class AbstractFetchParent implements FetchParent {
|
|||
|
||||
@Override
|
||||
public JavaType<?> getResultJavaType() {
|
||||
return fetchContainer.getJavaType();
|
||||
return getFetchContainer().getJavaType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchableContainer getReferencedMappingContainer() {
|
||||
return fetchContainer;
|
||||
return getFetchContainer();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -46,6 +46,7 @@ public class AggregateEmbeddableFetchImpl extends AbstractFetchParent implements
|
|||
private final TableGroup tableGroup;
|
||||
private final boolean hasTableGroup;
|
||||
private final SqlSelection aggregateSelection;
|
||||
private final EmbeddableMappingType fetchContainer;
|
||||
|
||||
public AggregateEmbeddableFetchImpl(
|
||||
NavigablePath navigablePath,
|
||||
|
@ -54,7 +55,8 @@ public class AggregateEmbeddableFetchImpl extends AbstractFetchParent implements
|
|||
FetchTiming fetchTiming,
|
||||
boolean hasTableGroup,
|
||||
DomainResultCreationState creationState) {
|
||||
super( embeddedPartDescriptor.getEmbeddableTypeDescriptor(), navigablePath );
|
||||
super( navigablePath );
|
||||
this.fetchContainer = embeddedPartDescriptor.getEmbeddableTypeDescriptor();
|
||||
|
||||
this.fetchParent = fetchParent;
|
||||
this.fetchTiming = fetchTiming;
|
||||
|
@ -84,7 +86,7 @@ public class AggregateEmbeddableFetchImpl extends AbstractFetchParent implements
|
|||
|
||||
final SqlExpressionResolver sqlExpressionResolver = sqlAstCreationState.getSqlExpressionResolver();
|
||||
final TableReference tableReference = tableGroup.getPrimaryTableReference();
|
||||
final SelectableMapping selectableMapping = embeddedPartDescriptor.getEmbeddableTypeDescriptor().getAggregateMapping();
|
||||
final SelectableMapping selectableMapping = fetchContainer.getAggregateMapping();
|
||||
final Expression expression = sqlExpressionResolver.resolveSqlExpression( tableReference, selectableMapping );
|
||||
final TypeConfiguration typeConfiguration = sqlAstCreationState.getCreationContext()
|
||||
.getSessionFactory()
|
||||
|
@ -115,7 +117,7 @@ public class AggregateEmbeddableFetchImpl extends AbstractFetchParent implements
|
|||
|
||||
@Override
|
||||
public EmbeddableMappingType getFetchContainer() {
|
||||
return (EmbeddableMappingType) super.getFetchContainer();
|
||||
return fetchContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -48,13 +48,15 @@ public class AggregateEmbeddableResultImpl<T> extends AbstractFetchParent implem
|
|||
private final boolean containsAnyNonScalars;
|
||||
private final NavigablePath initializerNavigablePath;
|
||||
private final SqlSelection aggregateSelection;
|
||||
private final EmbeddableMappingType fetchContainer;
|
||||
|
||||
public AggregateEmbeddableResultImpl(
|
||||
NavigablePath navigablePath,
|
||||
EmbeddableValuedModelPart embeddedPartDescriptor,
|
||||
String resultVariable,
|
||||
DomainResultCreationState creationState) {
|
||||
super( embeddedPartDescriptor.getEmbeddableTypeDescriptor(), navigablePath );
|
||||
super( navigablePath );
|
||||
this.fetchContainer = embeddedPartDescriptor.getEmbeddableTypeDescriptor();
|
||||
this.resultVariable = resultVariable;
|
||||
/*
|
||||
An `{embeddable_result}` sub-path is created for the corresponding initializer to differentiate it from a fetch-initializer if this embedded is also fetched.
|
||||
|
@ -127,7 +129,7 @@ public class AggregateEmbeddableResultImpl<T> extends AbstractFetchParent implem
|
|||
|
||||
@Override
|
||||
public EmbeddableMappingType getFetchContainer() {
|
||||
return (EmbeddableMappingType) super.getFetchContainer();
|
||||
return this.fetchContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.hibernate.type.spi.TypeConfiguration;
|
|||
public class EmbeddableExpressionResultImpl<T> extends AbstractFetchParent implements EmbeddableResultGraphNode, DomainResult<T>, EmbeddableResult<T> {
|
||||
private final String resultVariable;
|
||||
private final boolean containsAnyNonScalars;
|
||||
private final EmbeddableMappingType fetchContainer;
|
||||
|
||||
public EmbeddableExpressionResultImpl(
|
||||
NavigablePath navigablePath,
|
||||
|
@ -43,7 +44,8 @@ public class EmbeddableExpressionResultImpl<T> extends AbstractFetchParent imple
|
|||
SqlTuple sqlExpression,
|
||||
String resultVariable,
|
||||
DomainResultCreationState creationState) {
|
||||
super( modelPart.getEmbeddableTypeDescriptor(), navigablePath );
|
||||
super( navigablePath );
|
||||
this.fetchContainer = modelPart.getEmbeddableTypeDescriptor();
|
||||
this.resultVariable = resultVariable;
|
||||
|
||||
final ImmutableFetchList.Builder fetches = new ImmutableFetchList.Builder( modelPart );
|
||||
|
@ -100,7 +102,7 @@ public class EmbeddableExpressionResultImpl<T> extends AbstractFetchParent imple
|
|||
|
||||
@Override
|
||||
public EmbeddableMappingType getFetchContainer() {
|
||||
return (EmbeddableMappingType) super.getFetchContainer();
|
||||
return this.fetchContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -38,6 +38,7 @@ public class EmbeddableFetchImpl extends AbstractFetchParent implements Embeddab
|
|||
private final FetchTiming fetchTiming;
|
||||
private final TableGroup tableGroup;
|
||||
private final boolean hasTableGroup;
|
||||
private final EmbeddableMappingType fetchContainer;
|
||||
|
||||
public EmbeddableFetchImpl(
|
||||
NavigablePath navigablePath,
|
||||
|
@ -46,7 +47,8 @@ public class EmbeddableFetchImpl extends AbstractFetchParent implements Embeddab
|
|||
FetchTiming fetchTiming,
|
||||
boolean hasTableGroup,
|
||||
DomainResultCreationState creationState) {
|
||||
super( embeddedPartDescriptor.getEmbeddableTypeDescriptor(), navigablePath );
|
||||
super( navigablePath );
|
||||
this.fetchContainer = embeddedPartDescriptor.getEmbeddableTypeDescriptor();
|
||||
|
||||
this.fetchParent = fetchParent;
|
||||
this.fetchTiming = fetchTiming;
|
||||
|
@ -80,7 +82,8 @@ public class EmbeddableFetchImpl extends AbstractFetchParent implements Embeddab
|
|||
* For Hibernate Reactive
|
||||
*/
|
||||
protected EmbeddableFetchImpl(EmbeddableFetchImpl original) {
|
||||
super( original.getFetchContainer(), original.getNavigablePath() );
|
||||
super( original.getNavigablePath() );
|
||||
this.fetchContainer = original.getFetchContainer();
|
||||
fetchParent = original.fetchParent;
|
||||
fetchTiming = original.fetchTiming;
|
||||
tableGroup = original.tableGroup;
|
||||
|
@ -104,7 +107,7 @@ public class EmbeddableFetchImpl extends AbstractFetchParent implements Embeddab
|
|||
|
||||
@Override
|
||||
public EmbeddableMappingType getFetchContainer() {
|
||||
return (EmbeddableMappingType) super.getFetchContainer();
|
||||
return this.fetchContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,6 +34,7 @@ public class EmbeddableForeignKeyResultImpl<T>
|
|||
|
||||
private final String resultVariable;
|
||||
private final FetchParent fetchParent;
|
||||
private final EmbeddableMappingType fetchContainer;
|
||||
|
||||
public EmbeddableForeignKeyResultImpl(
|
||||
NavigablePath navigablePath,
|
||||
|
@ -41,7 +42,8 @@ public class EmbeddableForeignKeyResultImpl<T>
|
|||
String resultVariable,
|
||||
FetchParent fetchParent,
|
||||
DomainResultCreationState creationState) {
|
||||
super( embeddableValuedModelPart.getEmbeddableTypeDescriptor(), navigablePath );
|
||||
super( navigablePath );
|
||||
this.fetchContainer = embeddableValuedModelPart.getEmbeddableTypeDescriptor();
|
||||
this.resultVariable = resultVariable;
|
||||
this.fetchParent = fetchParent;
|
||||
resetFetches( creationState.visitFetches( this ) );
|
||||
|
@ -117,7 +119,7 @@ public class EmbeddableForeignKeyResultImpl<T>
|
|||
|
||||
@Override
|
||||
public EmbeddableMappingType getFetchContainer() {
|
||||
return (EmbeddableMappingType) super.getFetchContainer();
|
||||
return fetchContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,13 +33,15 @@ public class EmbeddableResultImpl<T> extends AbstractFetchParent implements Embe
|
|||
private final String resultVariable;
|
||||
private final boolean containsAnyNonScalars;
|
||||
private final NavigablePath initializerNavigablePath;
|
||||
private final EmbeddableMappingType fetchContainer;
|
||||
|
||||
public EmbeddableResultImpl(
|
||||
NavigablePath navigablePath,
|
||||
EmbeddableValuedModelPart modelPart,
|
||||
String resultVariable,
|
||||
DomainResultCreationState creationState) {
|
||||
super( modelPart.getEmbeddableTypeDescriptor(), navigablePath );
|
||||
super( navigablePath );
|
||||
this.fetchContainer = modelPart.getEmbeddableTypeDescriptor();
|
||||
this.resultVariable = resultVariable;
|
||||
/*
|
||||
An `{embeddable_result}` sub-path is created for the corresponding initializer to differentiate it from a fetch-initializer if this embedded is also fetched.
|
||||
|
@ -98,7 +100,7 @@ public class EmbeddableResultImpl<T> extends AbstractFetchParent implements Embe
|
|||
|
||||
@Override
|
||||
public EmbeddableMappingType getFetchContainer() {
|
||||
return (EmbeddableMappingType) super.getFetchContainer();
|
||||
return this.fetchContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.hibernate.sql.results.graph.DomainResult;
|
|||
import org.hibernate.sql.results.graph.DomainResultCreationState;
|
||||
import org.hibernate.sql.results.graph.Fetch;
|
||||
import org.hibernate.sql.results.graph.FetchParent;
|
||||
import org.hibernate.sql.results.graph.FetchableContainer;
|
||||
import org.hibernate.sql.results.graph.basic.BasicFetch;
|
||||
import org.hibernate.type.descriptor.java.JavaType;
|
||||
|
||||
|
@ -29,9 +30,11 @@ public abstract class AbstractEntityResultGraphNode extends AbstractFetchParent
|
|||
private Fetch identifierFetch;
|
||||
private BasicFetch<?> discriminatorFetch;
|
||||
private DomainResult<Object> rowIdResult;
|
||||
private final EntityValuedModelPart fetchContainer;
|
||||
|
||||
public AbstractEntityResultGraphNode(EntityValuedModelPart referencedModelPart, NavigablePath navigablePath) {
|
||||
super( referencedModelPart, navigablePath );
|
||||
super( navigablePath );
|
||||
this.fetchContainer = referencedModelPart;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -72,7 +75,12 @@ public abstract class AbstractEntityResultGraphNode extends AbstractFetchParent
|
|||
|
||||
@Override
|
||||
public EntityValuedModelPart getEntityValuedModelPart() {
|
||||
return (EntityValuedModelPart) getFetchContainer();
|
||||
return this.fetchContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchableContainer getFetchContainer() {
|
||||
return this.fetchContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,6 +13,7 @@ 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.FetchableContainer;
|
||||
import org.hibernate.sql.results.graph.entity.internal.EntityAssembler;
|
||||
|
||||
/**
|
||||
|
@ -22,18 +23,25 @@ import org.hibernate.sql.results.graph.entity.internal.EntityAssembler;
|
|||
*/
|
||||
public abstract class AbstractNonLazyEntityFetch extends AbstractFetchParent implements EntityFetch {
|
||||
private final FetchParent fetchParent;
|
||||
private final EntityValuedFetchable fetchContainer;
|
||||
|
||||
public AbstractNonLazyEntityFetch(
|
||||
FetchParent fetchParent,
|
||||
EntityValuedFetchable fetchedPart,
|
||||
NavigablePath navigablePath) {
|
||||
super( fetchedPart, navigablePath );
|
||||
super( navigablePath );
|
||||
this.fetchContainer = fetchedPart;
|
||||
this.fetchParent = fetchParent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityValuedFetchable getEntityValuedModelPart() {
|
||||
return (EntityValuedFetchable) getFetchContainer();
|
||||
return fetchContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchableContainer getFetchContainer() {
|
||||
return fetchContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue