Disable select item deduplication for query groups and deduplicate within a fetch parent
This commit is contained in:
parent
b4a1b149fb
commit
23098ca254
|
@ -19,6 +19,7 @@ import org.hibernate.sql.ast.tree.from.TableReference;
|
|||
import org.hibernate.sql.ast.tree.predicate.Predicate;
|
||||
import org.hibernate.sql.results.graph.DomainResult;
|
||||
import org.hibernate.sql.results.graph.DomainResultCreationState;
|
||||
import org.hibernate.sql.results.graph.FetchParent;
|
||||
|
||||
/**
|
||||
* Descriptor for foreign-keys
|
||||
|
@ -81,7 +82,7 @@ public interface ForeignKeyDescriptor extends VirtualModelPart, ValueMapping {
|
|||
DomainResult<?> createKeyDomainResult(
|
||||
NavigablePath navigablePath,
|
||||
TableGroup tableGroup,
|
||||
DomainResultCreationState creationState);
|
||||
FetchParent fetchParent, DomainResultCreationState creationState);
|
||||
|
||||
/**
|
||||
* Create a DomainResult for the target-side of the fk
|
||||
|
@ -89,18 +90,13 @@ public interface ForeignKeyDescriptor extends VirtualModelPart, ValueMapping {
|
|||
DomainResult<?> createTargetDomainResult(
|
||||
NavigablePath navigablePath,
|
||||
TableGroup tableGroup,
|
||||
DomainResultCreationState creationState);
|
||||
|
||||
DomainResult<?> createCollectionFetchDomainResult(
|
||||
NavigablePath collectionPath,
|
||||
TableGroup tableGroup,
|
||||
DomainResultCreationState creationState);
|
||||
FetchParent fetchParent, DomainResultCreationState creationState);
|
||||
|
||||
DomainResult<?> createDomainResult(
|
||||
NavigablePath navigablePath,
|
||||
TableGroup tableGroup,
|
||||
Nature side,
|
||||
DomainResultCreationState creationState);
|
||||
FetchParent fetchParent, DomainResultCreationState creationState);
|
||||
|
||||
Predicate generateJoinPredicate(
|
||||
TableGroup targetSideTableGroup,
|
||||
|
|
|
@ -130,7 +130,13 @@ public abstract class AbstractDiscriminatorMapping implements EntityDiscriminato
|
|||
TableGroup tableGroup,
|
||||
String resultVariable,
|
||||
DomainResultCreationState creationState) {
|
||||
final SqlSelection sqlSelection = resolveSqlSelection( navigablePath, getUnderlyingJdbcMappingType(), tableGroup, creationState.getSqlAstCreationState() );
|
||||
final SqlSelection sqlSelection = resolveSqlSelection(
|
||||
navigablePath,
|
||||
getUnderlyingJdbcMappingType(),
|
||||
tableGroup,
|
||||
null,
|
||||
creationState.getSqlAstCreationState()
|
||||
);
|
||||
|
||||
//noinspection unchecked
|
||||
return new BasicResult(
|
||||
|
@ -146,11 +152,13 @@ public abstract class AbstractDiscriminatorMapping implements EntityDiscriminato
|
|||
NavigablePath navigablePath,
|
||||
JdbcMapping jdbcMappingToUse,
|
||||
TableGroup tableGroup,
|
||||
FetchParent fetchParent,
|
||||
SqlAstCreationState creationState) {
|
||||
final SqlExpressionResolver expressionResolver = creationState.getSqlExpressionResolver();
|
||||
return expressionResolver.resolveSqlSelection(
|
||||
resolveSqlExpression( navigablePath, jdbcMappingToUse, tableGroup, creationState ),
|
||||
jdbcMappingToUse.getJavaTypeDescriptor(),
|
||||
fetchParent,
|
||||
creationState.getCreationContext().getSessionFactory().getTypeConfiguration()
|
||||
);
|
||||
}
|
||||
|
@ -170,7 +178,13 @@ public abstract class AbstractDiscriminatorMapping implements EntityDiscriminato
|
|||
|
||||
assert tableGroup != null;
|
||||
|
||||
final SqlSelection sqlSelection = resolveSqlSelection( fetchablePath, getUnderlyingJdbcMappingType(), tableGroup, creationState.getSqlAstCreationState() );
|
||||
final SqlSelection sqlSelection = resolveSqlSelection(
|
||||
fetchablePath,
|
||||
getUnderlyingJdbcMappingType(),
|
||||
tableGroup,
|
||||
fetchParent,
|
||||
creationState.getSqlAstCreationState()
|
||||
);
|
||||
|
||||
return new BasicFetch<>(
|
||||
sqlSelection.getValuesArrayPosition(),
|
||||
|
@ -188,7 +202,7 @@ public abstract class AbstractDiscriminatorMapping implements EntityDiscriminato
|
|||
NavigablePath navigablePath,
|
||||
TableGroup tableGroup,
|
||||
DomainResultCreationState creationState) {
|
||||
resolveSqlSelection( navigablePath, getUnderlyingJdbcMappingType(), tableGroup, creationState.getSqlAstCreationState() );
|
||||
resolveSqlSelection( navigablePath, getUnderlyingJdbcMappingType(), tableGroup, null, creationState.getSqlAstCreationState() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -198,7 +212,7 @@ public abstract class AbstractDiscriminatorMapping implements EntityDiscriminato
|
|||
DomainResultCreationState creationState,
|
||||
BiConsumer<SqlSelection, JdbcMapping> selectionConsumer) {
|
||||
selectionConsumer.accept(
|
||||
resolveSqlSelection( navigablePath, getUnderlyingJdbcMappingType(), tableGroup, creationState.getSqlAstCreationState() ),
|
||||
resolveSqlSelection( navigablePath, getUnderlyingJdbcMappingType(), tableGroup, null, creationState.getSqlAstCreationState() ),
|
||||
getJdbcMapping()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -274,6 +274,7 @@ public class AnyDiscriminatorPart implements BasicValuedModelPart, FetchOptions,
|
|||
final SqlSelection sqlSelection = sqlExpressionResolver.resolveSqlSelection(
|
||||
columnReference,
|
||||
jdbcMapping().getMappedJavaType(),
|
||||
fetchParent,
|
||||
sessionFactory.getTypeConfiguration()
|
||||
);
|
||||
|
||||
|
|
|
@ -199,6 +199,7 @@ public class AnyKeyPart implements BasicValuedModelPart, FetchOptions {
|
|||
final SqlSelection sqlSelection = sqlExpressionResolver.resolveSqlSelection(
|
||||
columnReference,
|
||||
getJavaType(),
|
||||
fetchParent,
|
||||
sessionFactory.getTypeConfiguration()
|
||||
);
|
||||
|
||||
|
|
|
@ -254,7 +254,7 @@ public class BasicAttributeMapping
|
|||
TableGroup tableGroup,
|
||||
String resultVariable,
|
||||
DomainResultCreationState creationState) {
|
||||
final SqlSelection sqlSelection = resolveSqlSelection( navigablePath, tableGroup, true, creationState );
|
||||
final SqlSelection sqlSelection = resolveSqlSelection( navigablePath, tableGroup, true, null, creationState );
|
||||
|
||||
//noinspection unchecked
|
||||
return new BasicResult(
|
||||
|
@ -270,6 +270,7 @@ public class BasicAttributeMapping
|
|||
NavigablePath navigablePath,
|
||||
TableGroup tableGroup,
|
||||
boolean allowFkOptimization,
|
||||
FetchParent fetchParent,
|
||||
DomainResultCreationState creationState) {
|
||||
final SqlExpressionResolver expressionResolver = creationState.getSqlAstCreationState().getSqlExpressionResolver();
|
||||
final TableReference tableReference = tableGroup.resolveTableReference(
|
||||
|
@ -291,6 +292,7 @@ public class BasicAttributeMapping
|
|||
)
|
||||
),
|
||||
valueConverter == null ? getMappedType().getMappedJavaType() : valueConverter.getRelationalJavaType(),
|
||||
fetchParent,
|
||||
creationState.getSqlAstCreationState().getCreationContext().getSessionFactory().getTypeConfiguration()
|
||||
);
|
||||
}
|
||||
|
@ -300,7 +302,7 @@ public class BasicAttributeMapping
|
|||
NavigablePath navigablePath,
|
||||
TableGroup tableGroup,
|
||||
DomainResultCreationState creationState) {
|
||||
resolveSqlSelection( navigablePath, tableGroup, true, creationState );
|
||||
resolveSqlSelection( navigablePath, tableGroup, true, null, creationState );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -309,7 +311,7 @@ public class BasicAttributeMapping
|
|||
TableGroup tableGroup,
|
||||
DomainResultCreationState creationState,
|
||||
BiConsumer<SqlSelection, JdbcMapping> selectionConsumer) {
|
||||
selectionConsumer.accept( resolveSqlSelection( navigablePath, tableGroup, true, creationState ), getJdbcMapping() );
|
||||
selectionConsumer.accept( resolveSqlSelection( navigablePath, tableGroup, true, null, creationState ), getJdbcMapping() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -336,7 +338,7 @@ public class BasicAttributeMapping
|
|||
|
||||
assert tableGroup != null;
|
||||
|
||||
final SqlSelection sqlSelection = resolveSqlSelection( fetchablePath, tableGroup, true, creationState );
|
||||
final SqlSelection sqlSelection = resolveSqlSelection( fetchablePath, tableGroup, true, fetchParent, creationState );
|
||||
valuesArrayPosition = sqlSelection.getValuesArrayPosition();
|
||||
}
|
||||
|
||||
|
|
|
@ -215,7 +215,7 @@ public class BasicEntityIdentifierMappingImpl implements BasicEntityIdentifierMa
|
|||
TableGroup tableGroup,
|
||||
String resultVariable,
|
||||
DomainResultCreationState creationState) {
|
||||
final SqlSelection sqlSelection = resolveSqlSelection( navigablePath, tableGroup, true, creationState );
|
||||
final SqlSelection sqlSelection = resolveSqlSelection( navigablePath, tableGroup, true, null, creationState );
|
||||
|
||||
return new BasicResult(
|
||||
sqlSelection.getValuesArrayPosition(),
|
||||
|
@ -230,7 +230,7 @@ public class BasicEntityIdentifierMappingImpl implements BasicEntityIdentifierMa
|
|||
NavigablePath navigablePath,
|
||||
TableGroup tableGroup,
|
||||
DomainResultCreationState creationState) {
|
||||
resolveSqlSelection( navigablePath, tableGroup, true, creationState );
|
||||
resolveSqlSelection( navigablePath, tableGroup, true, null, creationState );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -240,7 +240,7 @@ public class BasicEntityIdentifierMappingImpl implements BasicEntityIdentifierMa
|
|||
DomainResultCreationState creationState,
|
||||
BiConsumer<SqlSelection, JdbcMapping> selectionConsumer) {
|
||||
selectionConsumer.accept(
|
||||
resolveSqlSelection( navigablePath, tableGroup, true, creationState ),
|
||||
resolveSqlSelection( navigablePath, tableGroup, true, null, creationState ),
|
||||
getJdbcMapping()
|
||||
);
|
||||
}
|
||||
|
@ -249,6 +249,7 @@ public class BasicEntityIdentifierMappingImpl implements BasicEntityIdentifierMa
|
|||
NavigablePath navigablePath,
|
||||
TableGroup tableGroup,
|
||||
boolean allowFkOptimization,
|
||||
FetchParent fetchParent,
|
||||
DomainResultCreationState creationState) {
|
||||
final SqlExpressionResolver expressionResolver = creationState.getSqlAstCreationState()
|
||||
.getSqlExpressionResolver();
|
||||
|
@ -285,6 +286,7 @@ public class BasicEntityIdentifierMappingImpl implements BasicEntityIdentifierMa
|
|||
return expressionResolver.resolveSqlSelection(
|
||||
expression,
|
||||
idType.getExpressibleJavaType(),
|
||||
fetchParent,
|
||||
sessionFactory.getTypeConfiguration()
|
||||
);
|
||||
}
|
||||
|
@ -383,7 +385,7 @@ public class BasicEntityIdentifierMappingImpl implements BasicEntityIdentifierMa
|
|||
|
||||
assert tableGroup != null;
|
||||
|
||||
final SqlSelection sqlSelection = resolveSqlSelection( fetchablePath, tableGroup, false, creationState );
|
||||
final SqlSelection sqlSelection = resolveSqlSelection( fetchablePath, tableGroup, false, fetchParent, creationState );
|
||||
return new BasicFetch<>(
|
||||
sqlSelection.getValuesArrayPosition(),
|
||||
fetchParent,
|
||||
|
|
|
@ -151,7 +151,7 @@ public class BasicValuedCollectionPart
|
|||
TableGroup tableGroup,
|
||||
String resultVariable,
|
||||
DomainResultCreationState creationState) {
|
||||
final SqlSelection sqlSelection = resolveSqlSelection( navigablePath, tableGroup, true, creationState );
|
||||
final SqlSelection sqlSelection = resolveSqlSelection( navigablePath, tableGroup, true, null, creationState );
|
||||
|
||||
//noinspection unchecked
|
||||
return new BasicResult(
|
||||
|
@ -167,6 +167,7 @@ public class BasicValuedCollectionPart
|
|||
NavigablePath navigablePath,
|
||||
TableGroup tableGroup,
|
||||
boolean allowFkOptimization,
|
||||
FetchParent fetchParent,
|
||||
DomainResultCreationState creationState) {
|
||||
final SqlExpressionResolver exprResolver = creationState.getSqlAstCreationState().getSqlExpressionResolver();
|
||||
final TableGroup targetTableGroup;
|
||||
|
@ -197,6 +198,7 @@ public class BasicValuedCollectionPart
|
|||
)
|
||||
),
|
||||
getJavaType(),
|
||||
fetchParent,
|
||||
creationState.getSqlAstCreationState().getCreationContext().getSessionFactory().getTypeConfiguration()
|
||||
);
|
||||
}
|
||||
|
@ -204,7 +206,7 @@ public class BasicValuedCollectionPart
|
|||
@Override
|
||||
public void applySqlSelections(
|
||||
NavigablePath navigablePath, TableGroup tableGroup, DomainResultCreationState creationState) {
|
||||
resolveSqlSelection( navigablePath, tableGroup, true, creationState );
|
||||
resolveSqlSelection( navigablePath, tableGroup, true, null, creationState );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -213,7 +215,7 @@ public class BasicValuedCollectionPart
|
|||
TableGroup tableGroup,
|
||||
DomainResultCreationState creationState,
|
||||
BiConsumer<SqlSelection, JdbcMapping> selectionConsumer) {
|
||||
selectionConsumer.accept( resolveSqlSelection( navigablePath, tableGroup, true, creationState ), getJdbcMapping() );
|
||||
selectionConsumer.accept( resolveSqlSelection( navigablePath, tableGroup, true, null, creationState ), getJdbcMapping() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -263,7 +265,7 @@ public class BasicValuedCollectionPart
|
|||
final TableGroup tableGroup = creationState.getSqlAstCreationState()
|
||||
.getFromClauseAccess()
|
||||
.findTableGroup( parentNavigablePath );
|
||||
final SqlSelection sqlSelection = resolveSqlSelection( fetchablePath, tableGroup, true, creationState );
|
||||
final SqlSelection sqlSelection = resolveSqlSelection( fetchablePath, tableGroup, true, fetchParent, creationState );
|
||||
|
||||
return new BasicFetch<>(
|
||||
sqlSelection.getValuesArrayPosition(),
|
||||
|
|
|
@ -231,6 +231,7 @@ public class CollectionIdentifierDescriptorImpl implements CollectionIdentifierD
|
|||
)
|
||||
),
|
||||
type.getJavaTypeDescriptor(),
|
||||
fetchParent,
|
||||
sessionFactory.getTypeConfiguration()
|
||||
);
|
||||
|
||||
|
@ -271,6 +272,7 @@ public class CollectionIdentifierDescriptorImpl implements CollectionIdentifierD
|
|||
)
|
||||
),
|
||||
type.getJavaTypeDescriptor(),
|
||||
null,
|
||||
sessionFactory.getTypeConfiguration()
|
||||
);
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ import org.hibernate.sql.ast.tree.predicate.Junction;
|
|||
import org.hibernate.sql.ast.tree.predicate.Predicate;
|
||||
import org.hibernate.sql.results.graph.DomainResult;
|
||||
import org.hibernate.sql.results.graph.DomainResultCreationState;
|
||||
import org.hibernate.sql.results.graph.FetchParent;
|
||||
import org.hibernate.sql.results.graph.embeddable.internal.EmbeddableForeignKeyResultImpl;
|
||||
import org.hibernate.type.descriptor.java.JavaType;
|
||||
|
||||
|
@ -187,6 +188,7 @@ public class EmbeddedForeignKeyDescriptor implements ForeignKeyDescriptor {
|
|||
public DomainResult<?> createKeyDomainResult(
|
||||
NavigablePath navigablePath,
|
||||
TableGroup tableGroup,
|
||||
FetchParent fetchParent,
|
||||
DomainResultCreationState creationState) {
|
||||
return createDomainResult(
|
||||
navigablePath,
|
||||
|
@ -194,6 +196,7 @@ public class EmbeddedForeignKeyDescriptor implements ForeignKeyDescriptor {
|
|||
null,
|
||||
keyTable,
|
||||
keySide.getModelPart(),
|
||||
fetchParent,
|
||||
creationState
|
||||
);
|
||||
}
|
||||
|
@ -202,6 +205,7 @@ public class EmbeddedForeignKeyDescriptor implements ForeignKeyDescriptor {
|
|||
public DomainResult<?> createTargetDomainResult(
|
||||
NavigablePath navigablePath,
|
||||
TableGroup tableGroup,
|
||||
FetchParent fetchParent,
|
||||
DomainResultCreationState creationState) {
|
||||
assert tableGroup.getTableReference( navigablePath, targetTable ) != null;
|
||||
|
||||
|
@ -211,42 +215,17 @@ public class EmbeddedForeignKeyDescriptor implements ForeignKeyDescriptor {
|
|||
null,
|
||||
targetTable,
|
||||
targetSide.getModelPart(),
|
||||
fetchParent,
|
||||
creationState
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResult<?> createCollectionFetchDomainResult(
|
||||
NavigablePath collectionPath,
|
||||
TableGroup tableGroup,
|
||||
DomainResultCreationState creationState) {
|
||||
if ( targetTable.equals( keyTable ) ) {
|
||||
return createDomainResult(
|
||||
collectionPath,
|
||||
tableGroup,
|
||||
null,
|
||||
targetTable,
|
||||
targetSide.getModelPart(),
|
||||
creationState
|
||||
);
|
||||
}
|
||||
else {
|
||||
return createDomainResult(
|
||||
collectionPath,
|
||||
tableGroup,
|
||||
null,
|
||||
keyTable,
|
||||
keySide.getModelPart(),
|
||||
creationState
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResult<?> createDomainResult(
|
||||
NavigablePath navigablePath,
|
||||
TableGroup tableGroup,
|
||||
Nature side,
|
||||
FetchParent fetchParent,
|
||||
DomainResultCreationState creationState) {
|
||||
if ( side == Nature.KEY ) {
|
||||
return createDomainResult(
|
||||
|
@ -255,6 +234,7 @@ public class EmbeddedForeignKeyDescriptor implements ForeignKeyDescriptor {
|
|||
null,
|
||||
keyTable,
|
||||
keySide.getModelPart(),
|
||||
fetchParent,
|
||||
creationState
|
||||
);
|
||||
}
|
||||
|
@ -265,6 +245,7 @@ public class EmbeddedForeignKeyDescriptor implements ForeignKeyDescriptor {
|
|||
null,
|
||||
targetTable,
|
||||
targetSide.getModelPart(),
|
||||
fetchParent,
|
||||
creationState
|
||||
);
|
||||
}
|
||||
|
@ -276,7 +257,15 @@ public class EmbeddedForeignKeyDescriptor implements ForeignKeyDescriptor {
|
|||
TableGroup tableGroup,
|
||||
String resultVariable,
|
||||
DomainResultCreationState creationState) {
|
||||
return createDomainResult( navigablePath, tableGroup, resultVariable, keyTable, keySide.getModelPart(), creationState );
|
||||
return createDomainResult(
|
||||
navigablePath,
|
||||
tableGroup,
|
||||
resultVariable,
|
||||
keyTable,
|
||||
keySide.getModelPart(),
|
||||
null,
|
||||
creationState
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -302,6 +291,7 @@ public class EmbeddedForeignKeyDescriptor implements ForeignKeyDescriptor {
|
|||
String resultVariable,
|
||||
String columnContainingTable,
|
||||
EmbeddableValuedModelPart modelPart,
|
||||
FetchParent fetchParent,
|
||||
DomainResultCreationState creationState) {
|
||||
final NavigablePath resultNavigablePath;
|
||||
if ( modelPart == keySide.getModelPart() ) {
|
||||
|
@ -334,6 +324,7 @@ public class EmbeddedForeignKeyDescriptor implements ForeignKeyDescriptor {
|
|||
resultNavigablePath,
|
||||
modelPart,
|
||||
resultVariable,
|
||||
fetchParent,
|
||||
creationState
|
||||
);
|
||||
}
|
||||
|
|
|
@ -106,6 +106,7 @@ public class EntityRowIdMappingImpl implements EntityRowIdMapping, SelectableMap
|
|||
)
|
||||
),
|
||||
rowIdType.getJavaTypeDescriptor(),
|
||||
null,
|
||||
sqlAstCreationState.getCreationContext().getSessionFactory().getTypeConfiguration()
|
||||
);
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@ import org.hibernate.sql.results.graph.FetchParent;
|
|||
import org.hibernate.sql.results.graph.basic.BasicFetch;
|
||||
import org.hibernate.sql.results.graph.basic.BasicResult;
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.descriptor.java.JavaType;
|
||||
import org.hibernate.type.descriptor.java.VersionJavaType;
|
||||
|
||||
/**
|
||||
|
@ -228,6 +227,7 @@ public class EntityVersionMappingImpl implements EntityVersionMapping, FetchOpti
|
|||
)
|
||||
),
|
||||
versionBasicType.getJdbcMapping().getJavaTypeDescriptor(),
|
||||
fetchParent,
|
||||
sqlAstCreationState.getCreationContext().getSessionFactory().getTypeConfiguration()
|
||||
);
|
||||
|
||||
|
@ -302,6 +302,7 @@ public class EntityVersionMappingImpl implements EntityVersionMapping, FetchOpti
|
|||
)
|
||||
),
|
||||
versionBasicType.getJdbcMapping().getJavaTypeDescriptor(),
|
||||
null,
|
||||
sqlAstCreationState.getCreationContext().getSessionFactory().getTypeConfiguration()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -466,6 +466,7 @@ public class PluralAttributeMappingImpl
|
|||
final DomainResult<?> collectionKeyDomainResult = getKeyDescriptor().createTargetDomainResult(
|
||||
fetchablePath,
|
||||
sqlAstCreationState.getFromClauseAccess().getTableGroup( fetchParent.getNavigablePath() ),
|
||||
fetchParent,
|
||||
creationState
|
||||
);
|
||||
|
||||
|
@ -517,6 +518,7 @@ public class PluralAttributeMappingImpl
|
|||
collectionKeyDomainResult = getKeyDescriptor().createTargetDomainResult(
|
||||
fetchablePath,
|
||||
sqlAstCreationState.getFromClauseAccess().getTableGroup( fetchParent.getNavigablePath() ),
|
||||
fetchParent,
|
||||
creationState
|
||||
);
|
||||
}
|
||||
|
|
|
@ -157,44 +157,43 @@ public class SimpleForeignKeyDescriptor implements ForeignKeyDescriptor, BasicVa
|
|||
public DomainResult<?> createKeyDomainResult(
|
||||
NavigablePath navigablePath,
|
||||
TableGroup tableGroup,
|
||||
FetchParent fetchParent,
|
||||
DomainResultCreationState creationState) {
|
||||
return createDomainResult(
|
||||
navigablePath,
|
||||
tableGroup,
|
||||
keySide.getModelPart(),
|
||||
fetchParent,
|
||||
creationState
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResult<?> createTargetDomainResult(NavigablePath navigablePath, TableGroup tableGroup, DomainResultCreationState creationState) {
|
||||
public DomainResult<?> createTargetDomainResult(
|
||||
NavigablePath navigablePath,
|
||||
TableGroup tableGroup,
|
||||
FetchParent fetchParent,
|
||||
DomainResultCreationState creationState) {
|
||||
return createDomainResult(
|
||||
navigablePath,
|
||||
tableGroup,
|
||||
targetSide.getModelPart(),
|
||||
fetchParent,
|
||||
creationState
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResult<?> createCollectionFetchDomainResult(
|
||||
NavigablePath collectionPath,
|
||||
TableGroup tableGroup,
|
||||
DomainResultCreationState creationState) {
|
||||
return createDomainResult( collectionPath, tableGroup, targetSide.getModelPart(), creationState );
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResult<?> createDomainResult(
|
||||
NavigablePath navigablePath,
|
||||
TableGroup tableGroup,
|
||||
Nature side,
|
||||
DomainResultCreationState creationState) {
|
||||
FetchParent fetchParent, DomainResultCreationState creationState) {
|
||||
if ( side == Nature.KEY ) {
|
||||
return createDomainResult( navigablePath, tableGroup, keySide.getModelPart(), creationState );
|
||||
return createDomainResult( navigablePath, tableGroup, keySide.getModelPart(), fetchParent, creationState );
|
||||
}
|
||||
else {
|
||||
return createDomainResult( navigablePath, tableGroup, targetSide.getModelPart(), creationState );
|
||||
return createDomainResult( navigablePath, tableGroup, targetSide.getModelPart(), fetchParent, creationState );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -204,7 +203,7 @@ public class SimpleForeignKeyDescriptor implements ForeignKeyDescriptor, BasicVa
|
|||
TableGroup tableGroup,
|
||||
String resultVariable,
|
||||
DomainResultCreationState creationState) {
|
||||
return createDomainResult( navigablePath, tableGroup, keySide.getModelPart(), creationState );
|
||||
return createDomainResult( navigablePath, tableGroup, keySide.getModelPart(), null, creationState );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -228,6 +227,7 @@ public class SimpleForeignKeyDescriptor implements ForeignKeyDescriptor, BasicVa
|
|||
NavigablePath navigablePath,
|
||||
TableGroup tableGroup,
|
||||
SelectableMapping selectableMapping,
|
||||
FetchParent fetchParent,
|
||||
DomainResultCreationState creationState) {
|
||||
final SqlAstCreationState sqlAstCreationState = creationState.getSqlAstCreationState();
|
||||
final SqlExpressionResolver sqlExpressionResolver = sqlAstCreationState.getSqlExpressionResolver();
|
||||
|
@ -274,6 +274,7 @@ public class SimpleForeignKeyDescriptor implements ForeignKeyDescriptor, BasicVa
|
|||
)
|
||||
),
|
||||
selectableMapping.getJdbcMapping().getJavaTypeDescriptor(),
|
||||
fetchParent,
|
||||
sqlAstCreationState.getCreationContext().getSessionFactory().getTypeConfiguration()
|
||||
);
|
||||
|
||||
|
|
|
@ -803,6 +803,7 @@ public class ToOneAttributeMapping
|
|||
fetchablePath,
|
||||
parentTableGroup,
|
||||
sideNature,
|
||||
fetchParent,
|
||||
creationState
|
||||
);
|
||||
}
|
||||
|
@ -966,6 +967,7 @@ public class ToOneAttributeMapping
|
|||
creationState.getSqlAstCreationState()
|
||||
.getFromClauseAccess()
|
||||
.findTableGroup( realFetchParent.getNavigablePath() ),
|
||||
fetchParent,
|
||||
creationState
|
||||
);
|
||||
}
|
||||
|
@ -1023,6 +1025,7 @@ public class ToOneAttributeMapping
|
|||
fetchablePath,
|
||||
tableGroup,
|
||||
sideNature,
|
||||
fetchParent,
|
||||
creationState
|
||||
),
|
||||
isSelectByUniqueKey( sideNature )
|
||||
|
@ -1069,6 +1072,7 @@ public class ToOneAttributeMapping
|
|||
keyResult = foreignKeyDescriptor.createKeyDomainResult(
|
||||
fetchablePath,
|
||||
parentTableGroup,
|
||||
fetchParent,
|
||||
creationState
|
||||
);
|
||||
}
|
||||
|
@ -1076,6 +1080,7 @@ public class ToOneAttributeMapping
|
|||
keyResult = foreignKeyDescriptor.createTargetDomainResult(
|
||||
fetchablePath,
|
||||
parentTableGroup,
|
||||
fetchParent,
|
||||
creationState
|
||||
);
|
||||
}
|
||||
|
@ -1134,6 +1139,7 @@ public class ToOneAttributeMapping
|
|||
fetchablePath,
|
||||
parentTableGroup,
|
||||
side,
|
||||
fetchParent,
|
||||
creationState
|
||||
);
|
||||
final boolean selectByUniqueKey = isSelectByUniqueKey( side );
|
||||
|
|
|
@ -293,7 +293,7 @@ public class DomainResultCreationStateImpl
|
|||
public SqlSelection resolveSqlSelection(
|
||||
Expression expression,
|
||||
JavaType<?> javaType,
|
||||
TypeConfiguration typeConfiguration) {
|
||||
FetchParent fetchParent, TypeConfiguration typeConfiguration) {
|
||||
if ( expression == null ) {
|
||||
throw new IllegalArgumentException( "Expression cannot be null" );
|
||||
}
|
||||
|
|
|
@ -92,6 +92,7 @@ public class CompleteFetchBuilderEmbeddableValuedModelPart
|
|||
}
|
||||
),
|
||||
modelPart.getJavaType(),
|
||||
null,
|
||||
creationStateImpl.getSessionFactory().getTypeConfiguration()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -96,6 +96,7 @@ public class CompleteFetchBuilderEntityValuedModelPart
|
|||
}
|
||||
),
|
||||
modelPart.getJavaType(),
|
||||
null,
|
||||
creationStateImpl.getSessionFactory().getTypeConfiguration()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -87,6 +87,7 @@ public class CompleteResultBuilderBasicModelPart
|
|||
}
|
||||
),
|
||||
modelPart.getJavaType(),
|
||||
null,
|
||||
creationStateImpl.getSessionFactory().getTypeConfiguration()
|
||||
);
|
||||
|
||||
|
|
|
@ -132,6 +132,7 @@ public class CompleteResultBuilderBasicValuedConverted<O,R> implements CompleteR
|
|||
}
|
||||
),
|
||||
valueConverter.getDomainJavaType(),
|
||||
null,
|
||||
sessionFactory.getTypeConfiguration()
|
||||
);
|
||||
|
||||
|
|
|
@ -138,6 +138,7 @@ public class CompleteResultBuilderBasicValuedStandard implements CompleteResultB
|
|||
}
|
||||
),
|
||||
explicitJavaType,
|
||||
null,
|
||||
sessionFactory.getTypeConfiguration()
|
||||
);
|
||||
|
||||
|
|
|
@ -168,6 +168,7 @@ public class CompleteResultBuilderCollectionStandard implements CompleteResultBu
|
|||
}
|
||||
),
|
||||
selectableMapping.getJdbcMapping().getMappedJavaType(),
|
||||
null,
|
||||
creationStateImpl.getSessionFactory().getTypeConfiguration()
|
||||
);
|
||||
};
|
||||
|
|
|
@ -247,6 +247,7 @@ public class DynamicFetchBuilderLegacy implements DynamicFetchBuilder, NativeQue
|
|||
}
|
||||
),
|
||||
jdbcMapping.getMappedJavaType(),
|
||||
null,
|
||||
domainResultCreationState.getSqlAstCreationState().getCreationContext().getSessionFactory().getTypeConfiguration()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -97,6 +97,7 @@ public class DynamicFetchBuilderStandard
|
|||
}
|
||||
),
|
||||
selectableMapping.getJdbcMapping().getMappedJavaType(),
|
||||
null,
|
||||
domainResultCreationState.getSqlAstCreationState()
|
||||
.getCreationContext()
|
||||
.getSessionFactory()
|
||||
|
|
|
@ -89,6 +89,7 @@ public class DynamicResultBuilderAttribute implements DynamicResultBuilder, Nati
|
|||
}
|
||||
),
|
||||
attributeMapping.getJavaType(),
|
||||
null,
|
||||
domainResultCreationState.getSqlAstCreationState()
|
||||
.getCreationContext()
|
||||
.getSessionFactory()
|
||||
|
|
|
@ -127,6 +127,7 @@ public class DynamicResultBuilderBasicConverted<O,R> implements DynamicResultBui
|
|||
}
|
||||
),
|
||||
basicValueConverter.getDomainJavaType(),
|
||||
null,
|
||||
typeConfiguration
|
||||
);
|
||||
|
||||
|
|
|
@ -164,6 +164,7 @@ public class DynamicResultBuilderBasicStandard implements DynamicResultBuilderBa
|
|||
final SqlSelection sqlSelection = sqlExpressionResolver.resolveSqlSelection(
|
||||
expression,
|
||||
javaType,
|
||||
null,
|
||||
sessionFactory.getTypeConfiguration()
|
||||
);
|
||||
|
||||
|
|
|
@ -290,6 +290,7 @@ public class DynamicResultBuilderEntityStandard
|
|||
}
|
||||
),
|
||||
jdbcMapping.getMappedJavaType(),
|
||||
null,
|
||||
domainResultCreationState.getSqlAstCreationState().getCreationContext().getSessionFactory().getTypeConfiguration()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -86,6 +86,7 @@ public class ImplicitFetchBuilderBasic implements ImplicitFetchBuilder, BasicVal
|
|||
final SqlSelection sqlSelection = creationStateImpl.resolveSqlSelection(
|
||||
expression,
|
||||
fetchable.getJavaType(),
|
||||
parent,
|
||||
domainResultCreationState.getSqlAstCreationState()
|
||||
.getCreationContext()
|
||||
.getSessionFactory()
|
||||
|
|
|
@ -106,6 +106,7 @@ public class SelfRenderingFunctionSqlAstExpression
|
|||
.resolveSqlSelection(
|
||||
this,
|
||||
type.getExpressibleJavaType(),
|
||||
null,
|
||||
creationState.getSqlAstCreationState().getCreationContext().getMappingMetamodel().getTypeConfiguration()
|
||||
)
|
||||
.getValuesArrayPosition(),
|
||||
|
@ -183,6 +184,7 @@ public class SelfRenderingFunctionSqlAstExpression
|
|||
sqlExpressionResolver.resolveSqlSelection(
|
||||
this,
|
||||
type.getExpressibleJavaType(),
|
||||
null,
|
||||
sqlAstCreationState.getCreationContext().getMappingMetamodel().getTypeConfiguration()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -492,6 +492,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
this.deduplicateSelectionItems = deduplicateSelectionItems;
|
||||
|
||||
if ( statement instanceof SqmSelectStatement<?> ) {
|
||||
final SqmQueryPart<?> queryPart = ( (SqmSelectStatement<?>) statement ).getQueryPart();
|
||||
// NOTE: note the difference here between `JpaSelection#getSelectionItems`
|
||||
// and `SqmSelectClause#getSelections`.
|
||||
//
|
||||
|
@ -502,13 +503,21 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
// - `#getSelections` returns top-level selections. These are ultimately the
|
||||
// domain-results of the query
|
||||
this.domainResults = new ArrayList<>(
|
||||
( (SqmSelectStatement<?>) statement ).getQueryPart()
|
||||
.getFirstQuerySpec()
|
||||
queryPart.getFirstQuerySpec()
|
||||
.getSelectClause()
|
||||
.getSelections()
|
||||
.size()
|
||||
);
|
||||
|
||||
// We can't deduplicate select items with query groups,
|
||||
// otherwise a query might fail with inconsistent select items
|
||||
//
|
||||
// select e1.id, e1.id from Entity1 e1
|
||||
// union all
|
||||
// select e2.id, e2.parentId from Entity2 e2
|
||||
if ( queryPart instanceof SqmQueryGroup<?> ) {
|
||||
this.deduplicateSelectionItems = false;
|
||||
}
|
||||
final AppliedGraph appliedGraph = queryOptions.getAppliedGraph();
|
||||
if ( appliedGraph != null && appliedGraph.getSemantic() != null && appliedGraph.getGraph() != null ) {
|
||||
this.entityGraphTraversalState = new StandardEntityGraphTraversalStateImpl(
|
||||
|
@ -6914,8 +6923,9 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
public SqlSelection resolveSqlSelection(
|
||||
Expression expression,
|
||||
JavaType<?> javaType,
|
||||
FetchParent fetchParent,
|
||||
TypeConfiguration typeConfiguration) {
|
||||
return delegate.resolveSqlSelection( expression, javaType, typeConfiguration );
|
||||
return delegate.resolveSqlSelection( expression, javaType, fetchParent, typeConfiguration );
|
||||
}
|
||||
|
||||
public void setSqmAliasedNodeCollector(SqmAliasedNodeCollector sqmAliasedNodeCollector) {
|
||||
|
@ -6967,8 +6977,9 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
public SqlSelection resolveSqlSelection(
|
||||
Expression expression,
|
||||
JavaType<?> javaType,
|
||||
FetchParent fetchParent,
|
||||
TypeConfiguration typeConfiguration) {
|
||||
SqlSelection selection = delegate.resolveSqlSelection( expression, javaType, typeConfiguration );
|
||||
SqlSelection selection = delegate.resolveSqlSelection( expression, javaType, fetchParent, typeConfiguration );
|
||||
List<SqlSelection> sqlSelectionList = sqlSelectionsForSqmSelection[index];
|
||||
if ( sqlSelectionList == null ) {
|
||||
sqlSelectionsForSqmSelection[index] = sqlSelectionList = new ArrayList<>();
|
||||
|
|
|
@ -262,6 +262,7 @@ public class EntityValuedPathInterpretation<T> extends AbstractSqmPathInterpreta
|
|||
creationState.getSqlAstCreationState().getSqlExpressionResolver().resolveSqlSelection(
|
||||
sqlExpression,
|
||||
getExpressionType().getJavaType(),
|
||||
null,
|
||||
creationState.getSqlAstCreationState().getCreationContext().getMappingMetamodel().getTypeConfiguration()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
|||
import org.hibernate.sql.ast.spi.SqlSelection;
|
||||
import org.hibernate.sql.ast.tree.expression.Expression;
|
||||
import org.hibernate.sql.ast.tree.expression.SqlSelectionExpression;
|
||||
import org.hibernate.sql.results.graph.FetchParent;
|
||||
import org.hibernate.type.descriptor.java.JavaType;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
|
@ -139,7 +140,7 @@ public class SqlAstProcessingStateImpl
|
|||
public SqlSelection resolveSqlSelection(
|
||||
Expression expression,
|
||||
JavaType<?> javaType,
|
||||
TypeConfiguration typeConfiguration) {
|
||||
FetchParent fetchParent, TypeConfiguration typeConfiguration) {
|
||||
throw new ConversionException( "Unexpected call to resolve SqlSelection outside of QuerySpec processing" );
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.hibernate.sql.ast.tree.expression.Expression;
|
|||
import org.hibernate.sql.ast.tree.select.QueryPart;
|
||||
import org.hibernate.sql.ast.tree.select.QuerySpec;
|
||||
import org.hibernate.sql.ast.tree.select.SelectClause;
|
||||
import org.hibernate.sql.results.graph.FetchParent;
|
||||
import org.hibernate.type.descriptor.java.JavaType;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
|
@ -65,6 +66,7 @@ public class SqlAstQueryPartProcessingStateImpl
|
|||
// SqlExpressionResolver
|
||||
|
||||
private Map<Expression, SqlSelection> sqlSelectionMap;
|
||||
private Map<FetchParent, Map<Expression, SqlSelection>> fetchParentSqlSelectionMap;
|
||||
|
||||
@Override
|
||||
protected Map<Expression, SqlSelection> sqlSelectionMap() {
|
||||
|
@ -75,6 +77,7 @@ public class SqlAstQueryPartProcessingStateImpl
|
|||
public SqlSelection resolveSqlSelection(
|
||||
Expression expression,
|
||||
JavaType<?> javaType,
|
||||
FetchParent fetchParent,
|
||||
TypeConfiguration typeConfiguration) {
|
||||
final SqlSelection existing;
|
||||
if ( sqlSelectionMap == null ) {
|
||||
|
@ -88,6 +91,31 @@ public class SqlAstQueryPartProcessingStateImpl
|
|||
if ( existing != null && deduplicateSelectionItems ) {
|
||||
return existing;
|
||||
}
|
||||
final Map<Expression, SqlSelection> fetchParentSelections;
|
||||
if ( !deduplicateSelectionItems && fetchParent != null ) {
|
||||
// De-duplicate selection items within the root of a fetch parent
|
||||
final FetchParent root = fetchParent.getRoot();
|
||||
if ( fetchParentSqlSelectionMap == null ) {
|
||||
fetchParentSqlSelectionMap = new HashMap<>();
|
||||
fetchParentSqlSelectionMap.put( root, fetchParentSelections = new HashMap<>() );
|
||||
}
|
||||
else {
|
||||
final Map<Expression, SqlSelection> map = fetchParentSqlSelectionMap.get( root );
|
||||
if ( map == null ) {
|
||||
fetchParentSqlSelectionMap.put( root, fetchParentSelections = new HashMap<>() );
|
||||
}
|
||||
else {
|
||||
fetchParentSelections = map;
|
||||
}
|
||||
}
|
||||
final SqlSelection sqlSelection = fetchParentSelections.get( expression );
|
||||
if ( sqlSelection != null ) {
|
||||
return sqlSelection;
|
||||
}
|
||||
}
|
||||
else {
|
||||
fetchParentSelections = null;
|
||||
}
|
||||
|
||||
final SelectClause selectClause = ( (QuerySpec) queryPart ).getSelectClause();
|
||||
final int valuesArrayPosition = selectClause.getSqlSelections().size();
|
||||
|
@ -98,9 +126,13 @@ public class SqlAstQueryPartProcessingStateImpl
|
|||
typeConfiguration
|
||||
);
|
||||
|
||||
selectClause.addSqlSelection( sqlSelection );
|
||||
|
||||
sqlSelectionMap.put( expression, sqlSelection );
|
||||
|
||||
selectClause.addSqlSelection( sqlSelection );
|
||||
if ( fetchParentSelections != null ) {
|
||||
fetchParentSelections.put( expression, sqlSelection );
|
||||
}
|
||||
|
||||
return sqlSelection;
|
||||
}
|
||||
|
|
|
@ -120,6 +120,7 @@ public class SqmParameterInterpretation implements Expression, DomainResultProdu
|
|||
final SqlSelection sqlSelection = creationState.getSqlAstCreationState().getSqlExpressionResolver().resolveSqlSelection(
|
||||
resolvedExpression,
|
||||
sqmExpressible.getExpressibleJavaType(),
|
||||
null,
|
||||
sessionFactory.getTypeConfiguration()
|
||||
);
|
||||
|
||||
|
@ -164,6 +165,7 @@ public class SqmParameterInterpretation implements Expression, DomainResultProdu
|
|||
return creationState.getSqlAstCreationState().getSqlExpressionResolver().resolveSqlSelection(
|
||||
resolvedExpression,
|
||||
sqmExpressible.getExpressibleJavaType(),
|
||||
null,
|
||||
sessionFactory.getTypeConfiguration()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ public class Conversion
|
|||
creationState.getSqlAstCreationState().getSqlExpressionResolver().resolveSqlSelection(
|
||||
this,
|
||||
type.getJdbcMapping().getJavaTypeDescriptor(),
|
||||
null,
|
||||
creationState.getSqlAstCreationState().getCreationContext().getMappingMetamodel().getTypeConfiguration()
|
||||
).getValuesArrayPosition(),
|
||||
resultVariable,
|
||||
|
@ -78,6 +79,7 @@ public class Conversion
|
|||
sqlExpressionResolver.resolveSqlSelection(
|
||||
this,
|
||||
type.getJdbcMapping().getJavaTypeDescriptor(),
|
||||
null,
|
||||
sqlAstCreationState.getCreationContext().getMappingMetamodel().getTypeConfiguration()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.util.function.Function;
|
|||
import org.hibernate.metamodel.mapping.SelectableMapping;
|
||||
import org.hibernate.sql.ast.tree.expression.Expression;
|
||||
import org.hibernate.sql.ast.tree.from.TableReference;
|
||||
import org.hibernate.sql.results.graph.FetchParent;
|
||||
import org.hibernate.type.descriptor.java.JavaType;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
|
@ -77,5 +78,5 @@ public interface SqlExpressionResolver {
|
|||
SqlSelection resolveSqlSelection(
|
||||
Expression expression,
|
||||
JavaType<?> javaType,
|
||||
TypeConfiguration typeConfiguration);
|
||||
FetchParent fetchParent, TypeConfiguration typeConfiguration);
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ public class Any implements Expression, DomainResultProducer {
|
|||
creationState.getSqlAstCreationState().getSqlExpressionResolver().resolveSqlSelection(
|
||||
this,
|
||||
javaType,
|
||||
null,
|
||||
creationState.getSqlAstCreationState().getCreationContext().getMappingMetamodel().getTypeConfiguration()
|
||||
).getValuesArrayPosition(),
|
||||
resultVariable,
|
||||
|
@ -68,6 +69,7 @@ public class Any implements Expression, DomainResultProducer {
|
|||
sqlExpressionResolver.resolveSqlSelection(
|
||||
this,
|
||||
type.getJdbcMappings().get( 0 ).getJavaTypeDescriptor(),
|
||||
null,
|
||||
sqlAstCreationState.getCreationContext().getMappingMetamodel().getTypeConfiguration()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@ public class BinaryArithmeticExpression implements Expression, DomainResultProdu
|
|||
return creationState.getSqlAstCreationState().getSqlExpressionResolver().resolveSqlSelection(
|
||||
this,
|
||||
resultType.getJdbcMapping().getJavaTypeDescriptor(),
|
||||
null,
|
||||
creationState.getSqlAstCreationState().getCreationContext().getMappingMetamodel().getTypeConfiguration()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -68,6 +68,7 @@ public class CaseSearchedExpression implements Expression, DomainResultProducer
|
|||
.resolveSqlSelection(
|
||||
this,
|
||||
type.getExpressibleJavaType(),
|
||||
null,
|
||||
creationState.getSqlAstCreationState()
|
||||
.getCreationContext()
|
||||
.getSessionFactory()
|
||||
|
@ -89,6 +90,7 @@ public class CaseSearchedExpression implements Expression, DomainResultProducer
|
|||
sqlExpressionResolver.resolveSqlSelection(
|
||||
this,
|
||||
type.getExpressibleJavaType(),
|
||||
null,
|
||||
creationState.getSqlAstCreationState().getCreationContext().getMappingMetamodel().getTypeConfiguration()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ public class CaseSimpleExpression implements Expression, DomainResultProducer {
|
|||
creationState.getSqlAstCreationState().getSqlExpressionResolver().resolveSqlSelection(
|
||||
this,
|
||||
javaType,
|
||||
null,
|
||||
creationState.getSqlAstCreationState().getCreationContext().getMappingMetamodel().getTypeConfiguration()
|
||||
).getValuesArrayPosition(),
|
||||
resultVariable,
|
||||
|
@ -81,6 +82,7 @@ public class CaseSimpleExpression implements Expression, DomainResultProducer {
|
|||
sqlExpressionResolver.resolveSqlSelection(
|
||||
this,
|
||||
type.getJdbcMappings().get( 0 ).getJavaTypeDescriptor(),
|
||||
null,
|
||||
sqlAstCreationState.getCreationContext().getMappingMetamodel().getTypeConfiguration()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -76,6 +76,7 @@ public class ConvertedQueryLiteral<D,R> implements Literal, DomainResultProducer
|
|||
expressionResolver.resolveSqlSelection(
|
||||
this,
|
||||
relationalMapping.getExpressibleJavaType(),
|
||||
null,
|
||||
sqlAstCreationState.getCreationContext().getMappingMetamodel().getTypeConfiguration()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ public class Duration implements Expression, DomainResultProducer {
|
|||
creationState.getSqlAstCreationState().getSqlExpressionResolver().resolveSqlSelection(
|
||||
this,
|
||||
type.getJdbcMapping().getJavaTypeDescriptor(),
|
||||
null,
|
||||
creationState.getSqlAstCreationState().getCreationContext().getMappingMetamodel().getTypeConfiguration()
|
||||
).getValuesArrayPosition(),
|
||||
resultVariable,
|
||||
|
@ -76,6 +77,7 @@ public class Duration implements Expression, DomainResultProducer {
|
|||
sqlExpressionResolver.resolveSqlSelection(
|
||||
this,
|
||||
type.getJdbcMapping().getJavaTypeDescriptor(),
|
||||
null,
|
||||
sqlAstCreationState.getCreationContext().getMappingMetamodel().getTypeConfiguration()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -113,6 +113,7 @@ public class EntityTypeLiteral implements Expression, MappingModelExpressible, D
|
|||
.resolveSqlSelection(
|
||||
this,
|
||||
discriminatorType.getExpressibleJavaType(),
|
||||
null,
|
||||
creationState.getSqlAstCreationState().getCreationContext()
|
||||
.getMappingMetamodel().getTypeConfiguration()
|
||||
);
|
||||
|
|
|
@ -53,6 +53,7 @@ public class Every implements Expression, DomainResultProducer {
|
|||
creationState.getSqlAstCreationState().getSqlExpressionResolver().resolveSqlSelection(
|
||||
this,
|
||||
javaType,
|
||||
null,
|
||||
creationState.getSqlAstCreationState().getCreationContext().getMappingMetamodel().getTypeConfiguration()
|
||||
).getValuesArrayPosition(),
|
||||
resultVariable,
|
||||
|
@ -68,6 +69,7 @@ public class Every implements Expression, DomainResultProducer {
|
|||
sqlExpressionResolver.resolveSqlSelection(
|
||||
this,
|
||||
type.getJdbcMappings().get( 0 ).getJavaTypeDescriptor(),
|
||||
null,
|
||||
sqlAstCreationState.getCreationContext().getMappingMetamodel().getTypeConfiguration()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -140,6 +140,7 @@ public class JdbcLiteral<T> implements Literal, MappingModelExpressible<T>, Doma
|
|||
final SqlSelection sqlSelection = sqlExpressionResolver.resolveSqlSelection(
|
||||
this,
|
||||
jdbcMapping.getJavaTypeDescriptor(),
|
||||
null,
|
||||
sqlAstCreationState.getCreationContext().getMappingMetamodel().getTypeConfiguration()
|
||||
);
|
||||
|
||||
|
@ -155,6 +156,7 @@ public class JdbcLiteral<T> implements Literal, MappingModelExpressible<T>, Doma
|
|||
sqlExpressionResolver.resolveSqlSelection(
|
||||
this,
|
||||
jdbcMapping.getJavaTypeDescriptor(),
|
||||
null,
|
||||
sqlAstCreationState.getCreationContext().getMappingMetamodel().getTypeConfiguration()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -137,6 +137,7 @@ public class Over<T> implements Expression, DomainResultProducer<T> {
|
|||
return creationState.getSqlExpressionResolver().resolveSqlSelection(
|
||||
this,
|
||||
expression.getExpressionType().getJdbcMappings().get( 0 ).getMappedJavaType(),
|
||||
null,
|
||||
creationState.getCreationContext().getSessionFactory().getTypeConfiguration()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -105,6 +105,7 @@ public class QueryLiteral<T> implements Literal, DomainResultProducer<T> {
|
|||
final SqlSelection sqlSelection = sqlExpressionResolver.resolveSqlSelection(
|
||||
this,
|
||||
type.getMappedType().getMappedJavaType(),
|
||||
null,
|
||||
creationState.getSqlAstCreationState()
|
||||
.getCreationContext()
|
||||
.getSessionFactory()
|
||||
|
@ -147,6 +148,7 @@ public class QueryLiteral<T> implements Literal, DomainResultProducer<T> {
|
|||
creationState.getSqlAstCreationState().getSqlExpressionResolver().resolveSqlSelection(
|
||||
this,
|
||||
type.getJdbcMapping().getJavaTypeDescriptor(),
|
||||
null,
|
||||
creationState.getSqlAstCreationState().getCreationContext().getMappingMetamodel().getTypeConfiguration()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@ public class SqlTuple implements Expression, SqlTupleContainer, DomainResultProd
|
|||
valuesArrayPositions[i] = creationState.getSqlAstCreationState().getSqlExpressionResolver().resolveSqlSelection(
|
||||
expressions.get( i ),
|
||||
javaType,
|
||||
null,
|
||||
creationState.getSqlAstCreationState().getCreationContext().getMappingMetamodel().getTypeConfiguration()
|
||||
).getValuesArrayPosition();
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ public class UnaryOperation implements Expression, DomainResultProducer {
|
|||
final SqlSelection sqlSelection = creationState.getSqlAstCreationState().getSqlExpressionResolver().resolveSqlSelection(
|
||||
this,
|
||||
type.getJdbcMapping().getJavaTypeDescriptor(),
|
||||
null,
|
||||
creationState.getSqlAstCreationState().getCreationContext().getMappingMetamodel().getTypeConfiguration()
|
||||
);
|
||||
|
||||
|
@ -79,6 +80,7 @@ public class UnaryOperation implements Expression, DomainResultProducer {
|
|||
sqlExpressionResolver.resolveSqlSelection(
|
||||
this,
|
||||
type.getJdbcMapping().getJavaTypeDescriptor(),
|
||||
null,
|
||||
sqlAstCreationState.getCreationContext().getMappingMetamodel().getTypeConfiguration()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ public interface Predicate extends Expression, DomainResultProducer<Boolean> {
|
|||
final SqlSelection sqlSelection = sqlExpressionResolver.resolveSqlSelection(
|
||||
this,
|
||||
javaType,
|
||||
null,
|
||||
sqlAstCreationState.getCreationContext().getMappingMetamodel().getTypeConfiguration()
|
||||
);
|
||||
|
||||
|
@ -55,6 +56,7 @@ public interface Predicate extends Expression, DomainResultProducer<Boolean> {
|
|||
sqlExpressionResolver.resolveSqlSelection(
|
||||
this,
|
||||
getExpressionType().getJdbcMappings().get( 0 ).getJavaTypeDescriptor(),
|
||||
null,
|
||||
sqlAstCreationState.getCreationContext().getMappingMetamodel().getTypeConfiguration()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ import java.util.function.Function;
|
|||
|
||||
import org.hibernate.metamodel.mapping.JdbcMappingContainer;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
import org.hibernate.query.sqm.tree.expression.SqmAliasedNodeRef;
|
||||
import org.hibernate.sql.ast.SqlAstWalker;
|
||||
import org.hibernate.sql.ast.spi.SqlAstTreeHelper;
|
||||
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
||||
|
@ -154,6 +153,7 @@ public class QuerySpec extends QueryPart implements SqlAstNode, PredicateContain
|
|||
creationState.getSqlAstCreationState().getSqlExpressionResolver().resolveSqlSelection(
|
||||
this,
|
||||
jdbcMapping.getJavaTypeDescriptor(),
|
||||
null,
|
||||
typeConfiguration
|
||||
);
|
||||
}
|
||||
|
@ -175,6 +175,7 @@ public class QuerySpec extends QueryPart implements SqlAstNode, PredicateContain
|
|||
final SqlSelection sqlSelection = sqlExpressionResolver.resolveSqlSelection(
|
||||
this,
|
||||
descriptor,
|
||||
null,
|
||||
typeConfiguration
|
||||
);
|
||||
|
||||
|
|
|
@ -88,6 +88,13 @@ public interface FetchParent extends DomainResultGraphNode {
|
|||
|
||||
Fetch findFetch(Fetchable fetchable);
|
||||
|
||||
default FetchParent getRoot() {
|
||||
if ( this instanceof Fetch ) {
|
||||
return ( (Fetch) this ).getFetchParent().getRoot();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
default Fetch generateFetchableFetch(
|
||||
Fetchable fetchable,
|
||||
NavigablePath fetchablePath,
|
||||
|
|
|
@ -56,6 +56,7 @@ public class CollectionDomainResult implements DomainResult, CollectionResultGra
|
|||
fkResult = loadingAttribute.getKeyDescriptor().createKeyDomainResult(
|
||||
loadingPath,
|
||||
tableGroup,
|
||||
this,
|
||||
creationState
|
||||
);
|
||||
|
||||
|
|
|
@ -90,8 +90,18 @@ public class EagerCollectionFetch extends CollectionFetch implements FetchParent
|
|||
final ForeignKeyDescriptor keyDescriptor = fetchedAttribute.getKeyDescriptor();
|
||||
// The collection key must be fetched from the side of the declaring type of the attribute
|
||||
// So that this is guaranteed to be not-null
|
||||
collectionKeyResult = keyDescriptor.createTargetDomainResult( fetchedPath, parentTableGroup, creationState );
|
||||
collectionValueKeyResult = keyDescriptor.createKeyDomainResult( fetchedPath, collectionTableGroup, creationState );
|
||||
collectionKeyResult = keyDescriptor.createTargetDomainResult(
|
||||
fetchedPath,
|
||||
parentTableGroup,
|
||||
fetchParent,
|
||||
creationState
|
||||
);
|
||||
collectionValueKeyResult = keyDescriptor.createKeyDomainResult(
|
||||
fetchedPath,
|
||||
collectionTableGroup,
|
||||
fetchParent,
|
||||
creationState
|
||||
);
|
||||
|
||||
fetches = creationState.visitFetches( this );
|
||||
if ( fetchedAttribute.getIndexDescriptor() != null ) {
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.hibernate.sql.results.graph.DomainResult;
|
|||
import org.hibernate.sql.results.graph.DomainResultAssembler;
|
||||
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.FetchParentAccess;
|
||||
import org.hibernate.sql.results.graph.Fetchable;
|
||||
import org.hibernate.sql.results.graph.embeddable.EmbeddableInitializer;
|
||||
|
@ -31,17 +32,25 @@ public class EmbeddableForeignKeyResultImpl<T>
|
|||
implements EmbeddableResultGraphNode, DomainResult<T> {
|
||||
|
||||
private final String resultVariable;
|
||||
private final FetchParent fetchParent;
|
||||
|
||||
public EmbeddableForeignKeyResultImpl(
|
||||
NavigablePath navigablePath,
|
||||
EmbeddableValuedModelPart embeddableValuedModelPart,
|
||||
String resultVariable,
|
||||
FetchParent fetchParent,
|
||||
DomainResultCreationState creationState) {
|
||||
super( embeddableValuedModelPart.getEmbeddableTypeDescriptor(), navigablePath );
|
||||
this.resultVariable = resultVariable;
|
||||
this.fetchParent = fetchParent;
|
||||
this.fetches = creationState.visitFetches( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchParent getRoot() {
|
||||
return fetchParent.getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAnyNonScalarResults() {
|
||||
return true;
|
||||
|
|
|
@ -114,6 +114,7 @@ public abstract class AbstractEntityResultGraphNode extends AbstractFetchParent
|
|||
.createKeyDomainResult(
|
||||
navigablePath.getParent(),
|
||||
entityTableGroup,
|
||||
this,
|
||||
creationState
|
||||
);
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ public class EntityDelayedResultImpl implements DomainResult {
|
|||
this.identifierResult = entityValuedModelPart.getForeignKeyDescriptor().createKeyDomainResult(
|
||||
navigablePath.append( EntityIdentifierMapping.ROLE_LOCAL_NAME ),
|
||||
rootTableGroup,
|
||||
null,
|
||||
creationState
|
||||
);
|
||||
}
|
||||
|
|
|
@ -44,8 +44,13 @@ public class NotFoundSnapshotResult implements DomainResult {
|
|||
// however, that would mean a 1-1 with a join-table which
|
||||
// is pretty odd mapping
|
||||
final ForeignKeyDescriptor fkDescriptor = toOneMapping.getForeignKeyDescriptor();
|
||||
this.keyResult = fkDescriptor.createKeyDomainResult( navigablePath, keyTableGroup, creationState );
|
||||
this.targetResult = fkDescriptor.createTargetDomainResult( navigablePath, targetTableGroup, creationState );
|
||||
this.keyResult = fkDescriptor.createKeyDomainResult( navigablePath, keyTableGroup, null, creationState );
|
||||
this.targetResult = fkDescriptor.createTargetDomainResult(
|
||||
navigablePath,
|
||||
targetTableGroup,
|
||||
null,
|
||||
creationState
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue