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