HHH-13769: Avoid unnecessary joins
This commit is contained in:
parent
79c83cf8ba
commit
3be2369110
|
@ -83,7 +83,7 @@ class DatabaseSnapshotExecutor {
|
||||||
final TableGroup rootTableGroup = entityDescriptor.createRootTableGroup(
|
final TableGroup rootTableGroup = entityDescriptor.createRootTableGroup(
|
||||||
rootPath,
|
rootPath,
|
||||||
null,
|
null,
|
||||||
null,
|
true,
|
||||||
LockMode.NONE,
|
LockMode.NONE,
|
||||||
sqlAliasBaseManager,
|
sqlAliasBaseManager,
|
||||||
state.getSqlExpressionResolver(),
|
state.getSqlExpressionResolver(),
|
||||||
|
|
|
@ -192,7 +192,7 @@ public class LoaderSelectBuilder {
|
||||||
final TableGroup rootTableGroup = loadable.createRootTableGroup(
|
final TableGroup rootTableGroup = loadable.createRootTableGroup(
|
||||||
rootNavigablePath,
|
rootNavigablePath,
|
||||||
null,
|
null,
|
||||||
null,
|
true,
|
||||||
lockOptions.getLockMode(),
|
lockOptions.getLockMode(),
|
||||||
sqlAstCreationState.getSqlAliasBaseManager(),
|
sqlAstCreationState.getSqlAliasBaseManager(),
|
||||||
sqlAstCreationState.getSqlExpressionResolver(),
|
sqlAstCreationState.getSqlExpressionResolver(),
|
||||||
|
@ -449,7 +449,7 @@ public class LoaderSelectBuilder {
|
||||||
final TableGroup rootTableGroup = loadable.createRootTableGroup(
|
final TableGroup rootTableGroup = loadable.createRootTableGroup(
|
||||||
rootNavigablePath,
|
rootNavigablePath,
|
||||||
null,
|
null,
|
||||||
null,
|
true,
|
||||||
lockOptions.getLockMode(),
|
lockOptions.getLockMode(),
|
||||||
sqlAstCreationState.getSqlAliasBaseManager(),
|
sqlAstCreationState.getSqlAliasBaseManager(),
|
||||||
sqlAstCreationState.getSqlExpressionResolver(),
|
sqlAstCreationState.getSqlExpressionResolver(),
|
||||||
|
|
|
@ -15,7 +15,6 @@ import org.hibernate.engine.spi.LoadQueryInfluencers;
|
||||||
import org.hibernate.metamodel.mapping.ModelPart;
|
import org.hibernate.metamodel.mapping.ModelPart;
|
||||||
import org.hibernate.query.NavigablePath;
|
import org.hibernate.query.NavigablePath;
|
||||||
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
||||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||||
import org.hibernate.sql.ast.tree.from.RootTableGroupProducer;
|
import org.hibernate.sql.ast.tree.from.RootTableGroupProducer;
|
||||||
|
@ -42,7 +41,7 @@ public interface Loadable extends ModelPart, RootTableGroupProducer {
|
||||||
default TableGroup createRootTableGroup(
|
default TableGroup createRootTableGroup(
|
||||||
NavigablePath navigablePath,
|
NavigablePath navigablePath,
|
||||||
String explicitSourceAlias,
|
String explicitSourceAlias,
|
||||||
JoinType tableReferenceJoinType,
|
boolean canUseInnerJoins,
|
||||||
LockMode lockMode,
|
LockMode lockMode,
|
||||||
SqlAliasBaseGenerator aliasBaseGenerator,
|
SqlAliasBaseGenerator aliasBaseGenerator,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.metamodel.mapping;
|
package org.hibernate.metamodel.mapping;
|
||||||
|
|
||||||
|
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
||||||
|
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||||
|
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
||||||
|
import org.hibernate.sql.ast.tree.from.TableGroupBuilder;
|
||||||
|
import org.hibernate.sql.ast.tree.from.TableReference;
|
||||||
import org.hibernate.sql.results.graph.Fetchable;
|
import org.hibernate.sql.results.graph.Fetchable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,4 +67,6 @@ public interface CollectionPart extends ModelPart, Fetchable {
|
||||||
default String getPartName() {
|
default String getPartName() {
|
||||||
return getNature().getName();
|
return getNature().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void applyPrimaryTableReference(TableGroupBuilder tableGroupBuilder, SqlExpressionResolver sqlExpressionResolver, SqlAstCreationContext creationContext);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ import org.hibernate.loader.ast.spi.Loadable;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.query.NavigablePath;
|
import org.hibernate.query.NavigablePath;
|
||||||
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
|
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
||||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||||
|
@ -222,7 +222,7 @@ public interface EntityMappingType extends ManagedMappingType, Loadable {
|
||||||
default TableGroup createRootTableGroup(
|
default TableGroup createRootTableGroup(
|
||||||
NavigablePath navigablePath,
|
NavigablePath navigablePath,
|
||||||
String explicitSourceAlias,
|
String explicitSourceAlias,
|
||||||
JoinType tableReferenceJoinType,
|
boolean canUseInnerJoins,
|
||||||
LockMode lockMode,
|
LockMode lockMode,
|
||||||
SqlAliasBaseGenerator aliasBaseGenerator,
|
SqlAliasBaseGenerator aliasBaseGenerator,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
@ -231,7 +231,7 @@ public interface EntityMappingType extends ManagedMappingType, Loadable {
|
||||||
return getEntityPersister().createRootTableGroup(
|
return getEntityPersister().createRootTableGroup(
|
||||||
navigablePath,
|
navigablePath,
|
||||||
explicitSourceAlias,
|
explicitSourceAlias,
|
||||||
tableReferenceJoinType,
|
canUseInnerJoins,
|
||||||
lockMode,
|
lockMode,
|
||||||
aliasBaseGenerator,
|
aliasBaseGenerator,
|
||||||
sqlExpressionResolver,
|
sqlExpressionResolver,
|
||||||
|
@ -243,13 +243,13 @@ public interface EntityMappingType extends ManagedMappingType, Loadable {
|
||||||
@Override
|
@Override
|
||||||
default void applyTableReferences(
|
default void applyTableReferences(
|
||||||
SqlAliasBase sqlAliasBase,
|
SqlAliasBase sqlAliasBase,
|
||||||
JoinType baseJoinType,
|
SqlAstJoinType baseSqlAstJoinType,
|
||||||
TableReferenceCollector collector,
|
TableReferenceCollector collector,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
SqlAstCreationContext creationContext) {
|
SqlAstCreationContext creationContext) {
|
||||||
getEntityPersister().applyTableReferences(
|
getEntityPersister().applyTableReferences(
|
||||||
sqlAliasBase,
|
sqlAliasBase,
|
||||||
baseJoinType,
|
baseSqlAstJoinType,
|
||||||
collector,
|
collector,
|
||||||
sqlExpressionResolver,
|
sqlExpressionResolver,
|
||||||
creationContext
|
creationContext
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
package org.hibernate.metamodel.mapping;
|
package org.hibernate.metamodel.mapping;
|
||||||
|
|
||||||
import org.hibernate.query.NavigablePath;
|
import org.hibernate.query.NavigablePath;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||||
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
||||||
import org.hibernate.sql.ast.tree.from.TableGroup;
|
import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||||
|
@ -27,14 +27,14 @@ public interface ForeignKeyDescriptor extends VirtualModelPart {
|
||||||
Predicate generateJoinPredicate(
|
Predicate generateJoinPredicate(
|
||||||
TableGroup lhs,
|
TableGroup lhs,
|
||||||
TableGroup tableGroup,
|
TableGroup tableGroup,
|
||||||
JoinType joinType,
|
SqlAstJoinType sqlAstJoinType,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
SqlAstCreationContext creationContext);
|
SqlAstCreationContext creationContext);
|
||||||
|
|
||||||
Predicate generateJoinPredicate(
|
Predicate generateJoinPredicate(
|
||||||
TableReference lhs,
|
TableReference lhs,
|
||||||
TableReference rhs,
|
TableReference rhs,
|
||||||
JoinType joinType,
|
SqlAstJoinType sqlAstJoinType,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
SqlAstCreationContext creationContext);
|
SqlAstCreationContext creationContext);
|
||||||
|
|
||||||
|
|
|
@ -19,10 +19,14 @@ import org.hibernate.metamodel.mapping.MappingType;
|
||||||
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
|
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
|
||||||
import org.hibernate.persister.collection.CollectionPersister;
|
import org.hibernate.persister.collection.CollectionPersister;
|
||||||
import org.hibernate.query.NavigablePath;
|
import org.hibernate.query.NavigablePath;
|
||||||
|
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
||||||
|
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||||
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
||||||
import org.hibernate.sql.ast.spi.SqlSelection;
|
import org.hibernate.sql.ast.spi.SqlSelection;
|
||||||
import org.hibernate.sql.ast.tree.expression.ColumnReference;
|
import org.hibernate.sql.ast.tree.expression.ColumnReference;
|
||||||
import org.hibernate.sql.ast.tree.from.TableGroup;
|
import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||||
|
import org.hibernate.sql.ast.tree.from.TableGroupBuilder;
|
||||||
|
import org.hibernate.sql.ast.tree.from.TableReference;
|
||||||
import org.hibernate.sql.results.ResultsLogger;
|
import org.hibernate.sql.results.ResultsLogger;
|
||||||
import org.hibernate.sql.results.graph.basic.BasicFetch;
|
import org.hibernate.sql.results.graph.basic.BasicFetch;
|
||||||
import org.hibernate.sql.results.graph.basic.BasicResult;
|
import org.hibernate.sql.results.graph.basic.BasicResult;
|
||||||
|
@ -74,6 +78,14 @@ public class BasicValuedCollectionPart implements CollectionPart, BasicValuedMod
|
||||||
return mapper;
|
return mapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void applyPrimaryTableReference(
|
||||||
|
TableGroupBuilder tableGroupBuilder,
|
||||||
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
SqlAstCreationContext creationContext) {
|
||||||
|
// nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getContainingTableExpression() {
|
public String getContainingTableExpression() {
|
||||||
return tableExpression;
|
return tableExpression;
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
||||||
import org.hibernate.sql.ast.spi.SqlSelection;
|
import org.hibernate.sql.ast.spi.SqlSelection;
|
||||||
import org.hibernate.sql.ast.tree.expression.ColumnReference;
|
import org.hibernate.sql.ast.tree.expression.ColumnReference;
|
||||||
import org.hibernate.sql.ast.tree.from.TableGroup;
|
import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||||
|
import org.hibernate.sql.ast.tree.from.TableGroupBuilder;
|
||||||
import org.hibernate.sql.results.graph.basic.BasicFetch;
|
import org.hibernate.sql.results.graph.basic.BasicFetch;
|
||||||
import org.hibernate.sql.results.graph.basic.BasicResult;
|
import org.hibernate.sql.results.graph.basic.BasicResult;
|
||||||
import org.hibernate.sql.results.graph.DomainResult;
|
import org.hibernate.sql.results.graph.DomainResult;
|
||||||
|
@ -77,6 +78,14 @@ public class CollectionIdentifierDescriptorImpl implements CollectionIdentifierD
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void applyPrimaryTableReference(
|
||||||
|
TableGroupBuilder tableGroupBuilder,
|
||||||
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
SqlAstCreationContext creationContext) {
|
||||||
|
// nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JdbcMapping getJdbcMapping() {
|
public JdbcMapping getJdbcMapping() {
|
||||||
return type;
|
return type;
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.hibernate.engine.FetchStrategy;
|
||||||
import org.hibernate.engine.FetchTiming;
|
import org.hibernate.engine.FetchTiming;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||||
|
import org.hibernate.sql.ast.tree.from.TableReferenceJoin;
|
||||||
import org.hibernate.sql.results.graph.DomainResult;
|
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;
|
||||||
|
@ -36,7 +37,7 @@ import org.hibernate.property.access.spi.PropertyAccess;
|
||||||
import org.hibernate.query.NavigablePath;
|
import org.hibernate.query.NavigablePath;
|
||||||
import org.hibernate.query.sqm.sql.SqmToSqlAstConverter;
|
import org.hibernate.query.sqm.sql.SqmToSqlAstConverter;
|
||||||
import org.hibernate.sql.ast.Clause;
|
import org.hibernate.sql.ast.Clause;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
||||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||||
|
@ -234,7 +235,7 @@ public class EmbeddedAttributeMapping
|
||||||
NavigablePath navigablePath,
|
NavigablePath navigablePath,
|
||||||
TableGroup lhs,
|
TableGroup lhs,
|
||||||
String explicitSourceAlias,
|
String explicitSourceAlias,
|
||||||
JoinType joinType,
|
SqlAstJoinType sqlAstJoinType,
|
||||||
LockMode lockMode,
|
LockMode lockMode,
|
||||||
SqlAliasBaseGenerator aliasBaseGenerator,
|
SqlAliasBaseGenerator aliasBaseGenerator,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
@ -245,11 +246,11 @@ public class EmbeddedAttributeMapping
|
||||||
lhs
|
lhs
|
||||||
);
|
);
|
||||||
|
|
||||||
lhs.addTableGroupJoin( new TableGroupJoin( navigablePath, JoinType.INNER, compositeTableGroup, null ) );
|
lhs.addTableGroupJoin( new TableGroupJoin( navigablePath, SqlAstJoinType.INNER, compositeTableGroup, null ) );
|
||||||
|
|
||||||
return new TableGroupJoin(
|
return new TableGroupJoin(
|
||||||
navigablePath,
|
navigablePath,
|
||||||
joinType,
|
sqlAstJoinType,
|
||||||
compositeTableGroup
|
compositeTableGroup
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -257,7 +258,7 @@ public class EmbeddedAttributeMapping
|
||||||
@Override
|
@Override
|
||||||
public void applyTableReferences(
|
public void applyTableReferences(
|
||||||
SqlAliasBase sqlAliasBase,
|
SqlAliasBase sqlAliasBase,
|
||||||
JoinType baseJoinType,
|
SqlAstJoinType baseSqlAstJoinType,
|
||||||
TableReferenceCollector collector,
|
TableReferenceCollector collector,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
SqlAstCreationContext creationContext) {
|
SqlAstCreationContext creationContext) {
|
||||||
|
@ -266,7 +267,7 @@ public class EmbeddedAttributeMapping
|
||||||
if ( attrMapping instanceof TableGroupProducer ) {
|
if ( attrMapping instanceof TableGroupProducer ) {
|
||||||
( (TableGroupProducer) attrMapping ).applyTableReferences(
|
( (TableGroupProducer) attrMapping ).applyTableReferences(
|
||||||
sqlAliasBase,
|
sqlAliasBase,
|
||||||
baseJoinType,
|
baseSqlAstJoinType,
|
||||||
collector,
|
collector,
|
||||||
sqlExpressionResolver,
|
sqlExpressionResolver,
|
||||||
creationContext
|
creationContext
|
||||||
|
@ -275,7 +276,7 @@ public class EmbeddedAttributeMapping
|
||||||
else if ( attrMapping.getMappedTypeDescriptor() instanceof TableGroupProducer ) {
|
else if ( attrMapping.getMappedTypeDescriptor() instanceof TableGroupProducer ) {
|
||||||
( (TableGroupProducer) attrMapping.getMappedTypeDescriptor() ).applyTableReferences(
|
( (TableGroupProducer) attrMapping.getMappedTypeDescriptor() ).applyTableReferences(
|
||||||
sqlAliasBase,
|
sqlAliasBase,
|
||||||
baseJoinType,
|
baseSqlAstJoinType,
|
||||||
collector,
|
collector,
|
||||||
sqlExpressionResolver,
|
sqlExpressionResolver,
|
||||||
creationContext
|
creationContext
|
||||||
|
@ -285,6 +286,25 @@ public class EmbeddedAttributeMapping
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableReference createPrimaryTableReference(
|
||||||
|
SqlAliasBase sqlAliasBase,
|
||||||
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
SqlAstCreationContext creationContext) {
|
||||||
|
throw new UnsupportedOperationException( "Unexpected call to EmbeddedAttributeMapping#createPrimaryTableReference" );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableReferenceJoin createTableReferenceJoin(
|
||||||
|
String joinTableExpression,
|
||||||
|
SqlAliasBase sqlAliasBase,
|
||||||
|
TableReference lhs,
|
||||||
|
boolean canUseInnerJoin,
|
||||||
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
SqlAstCreationContext creationContext) {
|
||||||
|
throw new UnsupportedOperationException( "Unexpected call to EmbeddedAttributeMapping#createTableReferenceJoin" );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSqlAliasStem() {
|
public String getSqlAliasStem() {
|
||||||
return getAttributeName();
|
return getAttributeName();
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.hibernate.persister.collection.CollectionPersister;
|
||||||
import org.hibernate.query.NavigablePath;
|
import org.hibernate.query.NavigablePath;
|
||||||
import org.hibernate.query.sqm.sql.SqmToSqlAstConverter;
|
import org.hibernate.query.sqm.sql.SqmToSqlAstConverter;
|
||||||
import org.hibernate.sql.ast.Clause;
|
import org.hibernate.sql.ast.Clause;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
||||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||||
|
@ -34,8 +34,11 @@ import org.hibernate.sql.ast.tree.expression.Expression;
|
||||||
import org.hibernate.sql.ast.tree.expression.SqlTuple;
|
import org.hibernate.sql.ast.tree.expression.SqlTuple;
|
||||||
import org.hibernate.sql.ast.tree.from.CompositeTableGroup;
|
import org.hibernate.sql.ast.tree.from.CompositeTableGroup;
|
||||||
import org.hibernate.sql.ast.tree.from.TableGroup;
|
import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||||
|
import org.hibernate.sql.ast.tree.from.TableGroupBuilder;
|
||||||
import org.hibernate.sql.ast.tree.from.TableGroupJoin;
|
import org.hibernate.sql.ast.tree.from.TableGroupJoin;
|
||||||
|
import org.hibernate.sql.ast.tree.from.TableReference;
|
||||||
import org.hibernate.sql.ast.tree.from.TableReferenceCollector;
|
import org.hibernate.sql.ast.tree.from.TableReferenceCollector;
|
||||||
|
import org.hibernate.sql.ast.tree.from.TableReferenceJoin;
|
||||||
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;
|
||||||
|
@ -168,7 +171,7 @@ public class EmbeddedCollectionPart implements CollectionPart, EmbeddableValuedF
|
||||||
NavigablePath navigablePath,
|
NavigablePath navigablePath,
|
||||||
TableGroup lhs,
|
TableGroup lhs,
|
||||||
String explicitSourceAlias,
|
String explicitSourceAlias,
|
||||||
JoinType joinType,
|
SqlAstJoinType sqlAstJoinType,
|
||||||
LockMode lockMode,
|
LockMode lockMode,
|
||||||
SqlAliasBaseGenerator aliasBaseGenerator,
|
SqlAliasBaseGenerator aliasBaseGenerator,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
@ -179,7 +182,7 @@ public class EmbeddedCollectionPart implements CollectionPart, EmbeddableValuedF
|
||||||
|
|
||||||
return new TableGroupJoin(
|
return new TableGroupJoin(
|
||||||
navigablePath,
|
navigablePath,
|
||||||
joinType,
|
sqlAstJoinType,
|
||||||
tableGroup,
|
tableGroup,
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
@ -188,13 +191,39 @@ public class EmbeddedCollectionPart implements CollectionPart, EmbeddableValuedF
|
||||||
@Override
|
@Override
|
||||||
public void applyTableReferences(
|
public void applyTableReferences(
|
||||||
SqlAliasBase sqlAliasBase,
|
SqlAliasBase sqlAliasBase,
|
||||||
JoinType baseJoinType,
|
SqlAstJoinType baseSqlAstJoinType,
|
||||||
TableReferenceCollector collector,
|
TableReferenceCollector collector,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
SqlAstCreationContext creationContext) {
|
SqlAstCreationContext creationContext) {
|
||||||
// nothing to do
|
// nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void applyPrimaryTableReference(
|
||||||
|
TableGroupBuilder tableGroupBuilder,
|
||||||
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
SqlAstCreationContext creationContext) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableReference createPrimaryTableReference(
|
||||||
|
SqlAliasBase sqlAliasBase,
|
||||||
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
SqlAstCreationContext creationContext) {
|
||||||
|
throw new UnsupportedOperationException( "Unexpected call to EmbeddedCollectionPart#createPrimaryTableReference" );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableReferenceJoin createTableReferenceJoin(
|
||||||
|
String joinTableExpression,
|
||||||
|
SqlAliasBase sqlAliasBase,
|
||||||
|
TableReference lhs,
|
||||||
|
boolean canUseInnerJoin,
|
||||||
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
SqlAstCreationContext creationContext) {
|
||||||
|
throw new UnsupportedOperationException( "Unexpected call to EmbeddedCollectionPart#createTableReferenceJoin" );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSqlAliasStem() {
|
public String getSqlAliasStem() {
|
||||||
return sqlAliasStem;
|
return sqlAliasStem;
|
||||||
|
|
|
@ -15,6 +15,7 @@ import org.hibernate.engine.FetchStrategy;
|
||||||
import org.hibernate.engine.FetchTiming;
|
import org.hibernate.engine.FetchTiming;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||||
|
import org.hibernate.sql.ast.tree.from.TableReferenceJoin;
|
||||||
import org.hibernate.sql.results.graph.embeddable.EmbeddableValuedFetchable;
|
import org.hibernate.sql.results.graph.embeddable.EmbeddableValuedFetchable;
|
||||||
import org.hibernate.metamodel.mapping.ColumnConsumer;
|
import org.hibernate.metamodel.mapping.ColumnConsumer;
|
||||||
import org.hibernate.metamodel.mapping.EmbeddableMappingType;
|
import org.hibernate.metamodel.mapping.EmbeddableMappingType;
|
||||||
|
@ -29,7 +30,7 @@ import org.hibernate.property.access.spi.PropertyAccess;
|
||||||
import org.hibernate.query.NavigablePath;
|
import org.hibernate.query.NavigablePath;
|
||||||
import org.hibernate.query.sqm.sql.SqmToSqlAstConverter;
|
import org.hibernate.query.sqm.sql.SqmToSqlAstConverter;
|
||||||
import org.hibernate.sql.ast.Clause;
|
import org.hibernate.sql.ast.Clause;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
||||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||||
|
@ -195,7 +196,7 @@ public class EmbeddedIdentifierMappingImpl
|
||||||
NavigablePath navigablePath,
|
NavigablePath navigablePath,
|
||||||
TableGroup lhs,
|
TableGroup lhs,
|
||||||
String explicitSourceAlias,
|
String explicitSourceAlias,
|
||||||
JoinType joinType,
|
SqlAstJoinType sqlAstJoinType,
|
||||||
LockMode lockMode,
|
LockMode lockMode,
|
||||||
SqlAliasBaseGenerator aliasBaseGenerator,
|
SqlAliasBaseGenerator aliasBaseGenerator,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
@ -206,11 +207,11 @@ public class EmbeddedIdentifierMappingImpl
|
||||||
lhs
|
lhs
|
||||||
);
|
);
|
||||||
|
|
||||||
lhs.addTableGroupJoin( new TableGroupJoin( navigablePath, JoinType.INNER, compositeTableGroup, null ) );
|
lhs.addTableGroupJoin( new TableGroupJoin( navigablePath, SqlAstJoinType.INNER, compositeTableGroup, null ) );
|
||||||
|
|
||||||
return new TableGroupJoin(
|
return new TableGroupJoin(
|
||||||
navigablePath,
|
navigablePath,
|
||||||
joinType,
|
sqlAstJoinType,
|
||||||
compositeTableGroup
|
compositeTableGroup
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -234,7 +235,7 @@ public class EmbeddedIdentifierMappingImpl
|
||||||
@Override
|
@Override
|
||||||
public void applyTableReferences(
|
public void applyTableReferences(
|
||||||
SqlAliasBase sqlAliasBase,
|
SqlAliasBase sqlAliasBase,
|
||||||
JoinType baseJoinType,
|
SqlAstJoinType baseSqlAstJoinType,
|
||||||
TableReferenceCollector collector,
|
TableReferenceCollector collector,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
SqlAstCreationContext creationContext) {
|
SqlAstCreationContext creationContext) {
|
||||||
|
@ -243,7 +244,7 @@ public class EmbeddedIdentifierMappingImpl
|
||||||
if ( attrMapping instanceof TableGroupProducer ) {
|
if ( attrMapping instanceof TableGroupProducer ) {
|
||||||
( (TableGroupProducer) attrMapping ).applyTableReferences(
|
( (TableGroupProducer) attrMapping ).applyTableReferences(
|
||||||
sqlAliasBase,
|
sqlAliasBase,
|
||||||
baseJoinType,
|
baseSqlAstJoinType,
|
||||||
collector,
|
collector,
|
||||||
sqlExpressionResolver,
|
sqlExpressionResolver,
|
||||||
creationContext
|
creationContext
|
||||||
|
@ -252,7 +253,7 @@ public class EmbeddedIdentifierMappingImpl
|
||||||
else if ( attrMapping.getMappedTypeDescriptor() instanceof TableGroupProducer ) {
|
else if ( attrMapping.getMappedTypeDescriptor() instanceof TableGroupProducer ) {
|
||||||
( (TableGroupProducer) attrMapping.getMappedTypeDescriptor() ).applyTableReferences(
|
( (TableGroupProducer) attrMapping.getMappedTypeDescriptor() ).applyTableReferences(
|
||||||
sqlAliasBase,
|
sqlAliasBase,
|
||||||
baseJoinType,
|
baseSqlAstJoinType,
|
||||||
collector,
|
collector,
|
||||||
sqlExpressionResolver,
|
sqlExpressionResolver,
|
||||||
creationContext
|
creationContext
|
||||||
|
@ -262,6 +263,25 @@ public class EmbeddedIdentifierMappingImpl
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableReference createPrimaryTableReference(
|
||||||
|
SqlAliasBase sqlAliasBase,
|
||||||
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
SqlAstCreationContext creationContext) {
|
||||||
|
throw new UnsupportedOperationException( "Unexpected call to EmbeddedIdentifierImpl#createPrimaryTableReference" );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableReferenceJoin createTableReferenceJoin(
|
||||||
|
String joinTableExpression,
|
||||||
|
SqlAliasBase sqlAliasBase,
|
||||||
|
TableReference lhs,
|
||||||
|
boolean canUseInnerJoin,
|
||||||
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
SqlAstCreationContext creationContext) {
|
||||||
|
throw new UnsupportedOperationException( "Unexpected call to EmbeddedIdentifierImpl#createTableReferenceJoin" );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFetchableName() {
|
public String getFetchableName() {
|
||||||
return name;
|
return name;
|
||||||
|
|
|
@ -18,7 +18,14 @@ import org.hibernate.metamodel.mapping.ForeignKeyDescriptor;
|
||||||
import org.hibernate.metamodel.mapping.ModelPart;
|
import org.hibernate.metamodel.mapping.ModelPart;
|
||||||
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
|
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
|
||||||
import org.hibernate.query.NavigablePath;
|
import org.hibernate.query.NavigablePath;
|
||||||
|
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||||
|
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
||||||
|
import org.hibernate.sql.ast.spi.SqlAliasBaseManager;
|
||||||
|
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||||
|
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
||||||
import org.hibernate.sql.ast.tree.from.TableGroup;
|
import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||||
|
import org.hibernate.sql.ast.tree.from.TableGroupBuilder;
|
||||||
|
import org.hibernate.sql.ast.tree.from.TableReference;
|
||||||
import org.hibernate.sql.results.graph.DomainResult;
|
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.FetchParent;
|
import org.hibernate.sql.results.graph.FetchParent;
|
||||||
|
@ -71,6 +78,24 @@ public class EntityCollectionPart implements CollectionPart, EntityAssociationMa
|
||||||
return getEntityMappingType();
|
return getEntityMappingType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void applyPrimaryTableReference(
|
||||||
|
TableGroupBuilder tableGroupBuilder,
|
||||||
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
SqlAstCreationContext creationContext) {
|
||||||
|
tableGroupBuilder.applySecondaryTableReferences(
|
||||||
|
getEntityMappingType().createPrimaryTableReference( tableGroupBuilder.getSqlAliasBase(), sqlExpressionResolver, creationContext ),
|
||||||
|
SqlAstJoinType.LEFT,
|
||||||
|
(lhs, rhs, sqlAstJoinType) -> foreignKeyDescriptor.generateJoinPredicate(
|
||||||
|
lhs,
|
||||||
|
rhs,
|
||||||
|
sqlAstJoinType,
|
||||||
|
sqlExpressionResolver,
|
||||||
|
creationContext
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityMappingType getEntityMappingType() {
|
public EntityMappingType getEntityMappingType() {
|
||||||
return entityMappingType;
|
return entityMappingType;
|
||||||
|
@ -113,13 +138,19 @@ public class EntityCollectionPart implements CollectionPart, EntityAssociationMa
|
||||||
assert fetchParent.getReferencedMappingContainer() instanceof PluralAttributeMapping;
|
assert fetchParent.getReferencedMappingContainer() instanceof PluralAttributeMapping;
|
||||||
|
|
||||||
// find or create the TableGroup associated with this `fetchablePath`
|
// find or create the TableGroup associated with this `fetchablePath`
|
||||||
final TableGroup tableGroup = creationState.getSqlAstCreationState().getFromClauseAccess().resolveTableGroup(
|
creationState.getSqlAstCreationState().getFromClauseAccess().resolveTableGroup(
|
||||||
fetchablePath,
|
fetchablePath,
|
||||||
np -> {
|
np -> {
|
||||||
// we need to create one. first, find the collection's TableGroup
|
// We need to create one. The Result will be able to find it later by path
|
||||||
|
|
||||||
|
// first, find the collection's TableGroup
|
||||||
final TableGroup collectionTableGroup = creationState.getSqlAstCreationState()
|
final TableGroup collectionTableGroup = creationState.getSqlAstCreationState()
|
||||||
.getFromClauseAccess()
|
.getFromClauseAccess()
|
||||||
.getTableGroup( fetchablePath.getParent() );
|
.getTableGroup( fetchParent.getNavigablePath() );
|
||||||
|
|
||||||
|
assert collectionTableGroup != null;
|
||||||
|
|
||||||
|
// create a "wrapper" around the collection TableGroup adding in the entity's table references
|
||||||
return new EntityCollectionPartTableGroup( fetchablePath, collectionTableGroup, this );
|
return new EntityCollectionPartTableGroup( fetchablePath, collectionTableGroup, this );
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.hibernate.persister.collection.CollectionPersister;
|
||||||
import org.hibernate.persister.entity.Joinable;
|
import org.hibernate.persister.entity.Joinable;
|
||||||
import org.hibernate.property.access.spi.PropertyAccess;
|
import org.hibernate.property.access.spi.PropertyAccess;
|
||||||
import org.hibernate.query.NavigablePath;
|
import org.hibernate.query.NavigablePath;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasStemHelper;
|
import org.hibernate.sql.ast.spi.SqlAliasStemHelper;
|
||||||
|
@ -39,16 +39,17 @@ import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
||||||
import org.hibernate.sql.ast.tree.from.TableGroup;
|
import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||||
import org.hibernate.sql.ast.tree.from.TableGroupBuilder;
|
import org.hibernate.sql.ast.tree.from.TableGroupBuilder;
|
||||||
import org.hibernate.sql.ast.tree.from.TableGroupJoin;
|
import org.hibernate.sql.ast.tree.from.TableGroupJoin;
|
||||||
|
import org.hibernate.sql.ast.tree.from.TableReference;
|
||||||
import org.hibernate.sql.ast.tree.from.TableReferenceCollector;
|
import org.hibernate.sql.ast.tree.from.TableReferenceCollector;
|
||||||
import org.hibernate.sql.ast.tree.from.TableReferenceContributor;
|
import org.hibernate.sql.ast.tree.from.TableReferenceJoin;
|
||||||
import org.hibernate.sql.ast.tree.predicate.Predicate;
|
import org.hibernate.sql.ast.tree.predicate.Predicate;
|
||||||
import org.hibernate.sql.results.graph.collection.internal.CollectionDomainResult;
|
|
||||||
import org.hibernate.sql.results.graph.collection.internal.DelayedCollectionFetch;
|
|
||||||
import org.hibernate.sql.results.graph.collection.internal.EagerCollectionFetch;
|
|
||||||
import org.hibernate.sql.results.graph.DomainResult;
|
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.collection.internal.CollectionDomainResult;
|
||||||
|
import org.hibernate.sql.results.graph.collection.internal.DelayedCollectionFetch;
|
||||||
|
import org.hibernate.sql.results.graph.collection.internal.EagerCollectionFetch;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
|
@ -252,7 +253,7 @@ public class PluralAttributeMappingImpl extends AbstractAttributeMapping impleme
|
||||||
fetchablePath,
|
fetchablePath,
|
||||||
lhsTableGroup,
|
lhsTableGroup,
|
||||||
null,
|
null,
|
||||||
JoinType.LEFT,
|
SqlAstJoinType.LEFT,
|
||||||
lockMode,
|
lockMode,
|
||||||
creationState.getSqlAliasBaseManager(),
|
creationState.getSqlAliasBaseManager(),
|
||||||
creationState.getSqlAstCreationState().getSqlExpressionResolver(),
|
creationState.getSqlAstCreationState().getSqlExpressionResolver(),
|
||||||
|
@ -295,7 +296,7 @@ public class PluralAttributeMappingImpl extends AbstractAttributeMapping impleme
|
||||||
NavigablePath navigablePath,
|
NavigablePath navigablePath,
|
||||||
TableGroup lhs,
|
TableGroup lhs,
|
||||||
String explicitSourceAlias,
|
String explicitSourceAlias,
|
||||||
JoinType joinType,
|
SqlAstJoinType sqlAstJoinType,
|
||||||
LockMode lockMode,
|
LockMode lockMode,
|
||||||
SqlAliasBaseGenerator aliasBaseGenerator,
|
SqlAliasBaseGenerator aliasBaseGenerator,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
@ -308,12 +309,27 @@ public class PluralAttributeMappingImpl extends AbstractAttributeMapping impleme
|
||||||
this,
|
this,
|
||||||
lockMode,
|
lockMode,
|
||||||
sqlAliasBase,
|
sqlAliasBase,
|
||||||
|
(tableExpression, tableGroup) -> createTableReferenceJoin(
|
||||||
|
tableExpression,
|
||||||
|
sqlAliasBase,
|
||||||
|
tableGroup.getPrimaryTableReference(),
|
||||||
|
sqlAstJoinType == SqlAstJoinType.INNER && ! getAttributeMetadataAccess().resolveAttributeMetadata( null ).isNullable(),
|
||||||
|
sqlExpressionResolver,
|
||||||
|
creationContext
|
||||||
|
),
|
||||||
creationContext.getSessionFactory()
|
creationContext.getSessionFactory()
|
||||||
);
|
);
|
||||||
|
|
||||||
applyTableReferences(
|
tableGroupBuilder.applyPrimaryReference(
|
||||||
sqlAliasBase,
|
// returns null when there is no "collection table"
|
||||||
joinType,
|
getCollectionDescriptor().createPrimaryTableReference(
|
||||||
|
sqlAliasBase,
|
||||||
|
sqlExpressionResolver,
|
||||||
|
creationContext
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
elementDescriptor.applyPrimaryTableReference(
|
||||||
tableGroupBuilder,
|
tableGroupBuilder,
|
||||||
sqlExpressionResolver,
|
sqlExpressionResolver,
|
||||||
creationContext
|
creationContext
|
||||||
|
@ -322,12 +338,12 @@ public class PluralAttributeMappingImpl extends AbstractAttributeMapping impleme
|
||||||
final TableGroup tableGroup = tableGroupBuilder.build();
|
final TableGroup tableGroup = tableGroupBuilder.build();
|
||||||
final TableGroupJoin tableGroupJoin = new TableGroupJoin(
|
final TableGroupJoin tableGroupJoin = new TableGroupJoin(
|
||||||
navigablePath,
|
navigablePath,
|
||||||
joinType,
|
sqlAstJoinType,
|
||||||
tableGroup,
|
tableGroup,
|
||||||
getKeyDescriptor().generateJoinPredicate(
|
getKeyDescriptor().generateJoinPredicate(
|
||||||
lhs,
|
lhs,
|
||||||
tableGroup,
|
tableGroup,
|
||||||
joinType,
|
sqlAstJoinType,
|
||||||
sqlExpressionResolver,
|
sqlExpressionResolver,
|
||||||
creationContext
|
creationContext
|
||||||
)
|
)
|
||||||
|
@ -338,21 +354,57 @@ public class PluralAttributeMappingImpl extends AbstractAttributeMapping impleme
|
||||||
return tableGroupJoin;
|
return tableGroupJoin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableReferenceJoin createTableReferenceJoin(
|
||||||
|
String joinTableExpression,
|
||||||
|
SqlAliasBase sqlAliasBase,
|
||||||
|
TableReference lhs,
|
||||||
|
boolean sqlAstJoinType,
|
||||||
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
SqlAstCreationContext creationContext) {
|
||||||
|
return getCollectionDescriptor().createTableReferenceJoin(
|
||||||
|
joinTableExpression,
|
||||||
|
sqlAliasBase,
|
||||||
|
lhs,
|
||||||
|
sqlAstJoinType,
|
||||||
|
sqlExpressionResolver,
|
||||||
|
creationContext
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableReference createPrimaryTableReference(
|
||||||
|
SqlAliasBase sqlAliasBase,
|
||||||
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
SqlAstCreationContext creationContext) {
|
||||||
|
return getCollectionDescriptor().createPrimaryTableReference(
|
||||||
|
sqlAliasBase,
|
||||||
|
sqlExpressionResolver,
|
||||||
|
creationContext
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void applyTableReferences(
|
public void applyTableReferences(
|
||||||
SqlAliasBase sqlAliasBase,
|
SqlAliasBase sqlAliasBase,
|
||||||
JoinType baseJoinType,
|
SqlAstJoinType baseSqlAstJoinType,
|
||||||
TableReferenceCollector collector,
|
TableReferenceCollector collector,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
SqlAstCreationContext creationContext) {
|
SqlAstCreationContext creationContext) {
|
||||||
getCollectionDescriptor().applyTableReferences( sqlAliasBase, baseJoinType, collector, sqlExpressionResolver, creationContext );
|
getCollectionDescriptor().applyTableReferences(
|
||||||
|
sqlAliasBase,
|
||||||
|
baseSqlAstJoinType,
|
||||||
|
collector,
|
||||||
|
sqlExpressionResolver,
|
||||||
|
creationContext
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableGroup createRootTableGroup(
|
public TableGroup createRootTableGroup(
|
||||||
NavigablePath navigablePath,
|
NavigablePath navigablePath,
|
||||||
String explicitSourceAlias,
|
String explicitSourceAlias,
|
||||||
JoinType tableReferenceJoinType,
|
boolean canUseInnerJoins,
|
||||||
LockMode lockMode,
|
LockMode lockMode,
|
||||||
SqlAliasBaseGenerator aliasBaseGenerator,
|
SqlAliasBaseGenerator aliasBaseGenerator,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
@ -365,17 +417,54 @@ public class PluralAttributeMappingImpl extends AbstractAttributeMapping impleme
|
||||||
this,
|
this,
|
||||||
lockMode,
|
lockMode,
|
||||||
sqlAliasBase,
|
sqlAliasBase,
|
||||||
|
(tableExpression, tableGroup) -> createTableReferenceJoin(
|
||||||
|
tableExpression,
|
||||||
|
sqlAliasBase,
|
||||||
|
tableGroup.getPrimaryTableReference(),
|
||||||
|
canUseInnerJoins && ! getAttributeMetadataAccess().resolveAttributeMetadata( null ).isNullable(),
|
||||||
|
sqlExpressionResolver,
|
||||||
|
creationContext
|
||||||
|
),
|
||||||
creationContext.getSessionFactory()
|
creationContext.getSessionFactory()
|
||||||
);
|
);
|
||||||
|
|
||||||
applyTableReferences(
|
getElementDescriptor().applyPrimaryTableReference(
|
||||||
sqlAliasBase,
|
|
||||||
tableReferenceJoinType,
|
|
||||||
tableGroupBuilder,
|
tableGroupBuilder,
|
||||||
sqlExpressionResolver,
|
sqlExpressionResolver,
|
||||||
creationContext
|
creationContext
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ( getIndexDescriptor() != null ) {
|
||||||
|
getIndexDescriptor().applyPrimaryTableReference(
|
||||||
|
tableGroupBuilder,
|
||||||
|
sqlExpressionResolver,
|
||||||
|
creationContext
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
final TableReference collectionTableReference = getCollectionDescriptor().createPrimaryTableReference(
|
||||||
|
sqlAliasBase,
|
||||||
|
sqlExpressionResolver,
|
||||||
|
creationContext
|
||||||
|
);
|
||||||
|
|
||||||
|
if ( collectionTableReference != null ) {
|
||||||
|
tableGroupBuilder.applySecondaryTableReferences(
|
||||||
|
collectionTableReference,
|
||||||
|
canUseInnerJoins && ! getAttributeMetadataAccess().resolveAttributeMetadata( null ).isNullable()
|
||||||
|
? SqlAstJoinType.INNER
|
||||||
|
: SqlAstJoinType.LEFT,
|
||||||
|
(lhs, rhs, sqlAstJoinType) -> fkDescriptor.generateJoinPredicate(
|
||||||
|
lhs,
|
||||||
|
rhs,
|
||||||
|
sqlAstJoinType,
|
||||||
|
sqlExpressionResolver,
|
||||||
|
creationContext
|
||||||
|
)
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return tableGroupBuilder.build();
|
return tableGroupBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
|
||||||
import org.hibernate.query.ComparisonOperator;
|
import org.hibernate.query.ComparisonOperator;
|
||||||
import org.hibernate.query.NavigablePath;
|
import org.hibernate.query.NavigablePath;
|
||||||
import org.hibernate.sql.ast.Clause;
|
import org.hibernate.sql.ast.Clause;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||||
import org.hibernate.sql.ast.spi.SqlAstCreationState;
|
import org.hibernate.sql.ast.spi.SqlAstCreationState;
|
||||||
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
||||||
|
@ -109,7 +109,7 @@ public class SimpleForeignKeyDescriptor implements ForeignKeyDescriptor, BasicVa
|
||||||
public Predicate generateJoinPredicate(
|
public Predicate generateJoinPredicate(
|
||||||
TableReference lhs,
|
TableReference lhs,
|
||||||
TableReference rhs,
|
TableReference rhs,
|
||||||
JoinType joinType,
|
SqlAstJoinType sqlAstJoinType,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
SqlAstCreationContext creationContext) {
|
SqlAstCreationContext creationContext) {
|
||||||
if ( lhs.getTableExpression().equals( keyColumnContainingTable ) ) {
|
if ( lhs.getTableExpression().equals( keyColumnContainingTable ) ) {
|
||||||
|
@ -154,7 +154,7 @@ public class SimpleForeignKeyDescriptor implements ForeignKeyDescriptor, BasicVa
|
||||||
public Predicate generateJoinPredicate(
|
public Predicate generateJoinPredicate(
|
||||||
TableGroup lhs,
|
TableGroup lhs,
|
||||||
TableGroup tableGroup,
|
TableGroup tableGroup,
|
||||||
JoinType joinType,
|
SqlAstJoinType sqlAstJoinType,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
SqlAstCreationContext creationContext) {
|
SqlAstCreationContext creationContext) {
|
||||||
final TableReference keyTableReference = getTableReference( lhs, tableGroup, keyColumnContainingTable );
|
final TableReference keyTableReference = getTableReference( lhs, tableGroup, keyColumnContainingTable );
|
||||||
|
@ -244,10 +244,9 @@ public class SimpleForeignKeyDescriptor implements ForeignKeyDescriptor, BasicVa
|
||||||
return tableGroup.getPrimaryTableReference();
|
return tableGroup.getPrimaryTableReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( TableReferenceJoin tableJoin : lhs.getTableReferenceJoins() ) {
|
final TableReference tableReference = lhs.resolveTableReference( table );
|
||||||
if ( tableJoin.getJoinedTableReference().getTableExpression().equals( table ) ) {
|
if ( tableReference != null ) {
|
||||||
return tableJoin.getJoinedTableReference();
|
return tableReference;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new IllegalStateException( "Could not resolve binding for table `" + table + "`" );
|
throw new IllegalStateException( "Could not resolve binding for table `" + table + "`" );
|
||||||
|
|
|
@ -20,7 +20,7 @@ import org.hibernate.metamodel.mapping.StateArrayContributorMetadataAccess;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.property.access.spi.PropertyAccess;
|
import org.hibernate.property.access.spi.PropertyAccess;
|
||||||
import org.hibernate.query.NavigablePath;
|
import org.hibernate.query.NavigablePath;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasStemHelper;
|
import org.hibernate.sql.ast.spi.SqlAliasStemHelper;
|
||||||
|
@ -32,7 +32,9 @@ import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||||
import org.hibernate.sql.ast.tree.from.TableGroupBuilder;
|
import org.hibernate.sql.ast.tree.from.TableGroupBuilder;
|
||||||
import org.hibernate.sql.ast.tree.from.TableGroupJoin;
|
import org.hibernate.sql.ast.tree.from.TableGroupJoin;
|
||||||
import org.hibernate.sql.ast.tree.from.TableGroupJoinProducer;
|
import org.hibernate.sql.ast.tree.from.TableGroupJoinProducer;
|
||||||
|
import org.hibernate.sql.ast.tree.from.TableReference;
|
||||||
import org.hibernate.sql.ast.tree.from.TableReferenceCollector;
|
import org.hibernate.sql.ast.tree.from.TableReferenceCollector;
|
||||||
|
import org.hibernate.sql.ast.tree.from.TableReferenceJoin;
|
||||||
import org.hibernate.sql.ast.tree.predicate.Predicate;
|
import org.hibernate.sql.ast.tree.predicate.Predicate;
|
||||||
import org.hibernate.sql.results.graph.DomainResult;
|
import org.hibernate.sql.results.graph.DomainResult;
|
||||||
import org.hibernate.sql.results.graph.DomainResultCreationState;
|
import org.hibernate.sql.results.graph.DomainResultCreationState;
|
||||||
|
@ -120,18 +122,18 @@ public class SingularAssociationAttributeMapping extends AbstractSingularAttribu
|
||||||
|
|
||||||
if ( fetchTiming == FetchTiming.IMMEDIATE && selected ) {
|
if ( fetchTiming == FetchTiming.IMMEDIATE && selected ) {
|
||||||
if ( sqlAstCreationState.getFromClauseAccess().findTableGroup( fetchablePath ) == null ) {
|
if ( sqlAstCreationState.getFromClauseAccess().findTableGroup( fetchablePath ) == null ) {
|
||||||
JoinType joinType;
|
SqlAstJoinType sqlAstJoinType;
|
||||||
if ( isNullable ) {
|
if ( isNullable ) {
|
||||||
joinType = JoinType.LEFT;
|
sqlAstJoinType = SqlAstJoinType.LEFT;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
joinType = JoinType.INNER;
|
sqlAstJoinType = SqlAstJoinType.INNER;
|
||||||
}
|
}
|
||||||
final TableGroupJoin tableGroupJoin = createTableGroupJoin(
|
final TableGroupJoin tableGroupJoin = createTableGroupJoin(
|
||||||
fetchablePath,
|
fetchablePath,
|
||||||
lhsTableGroup,
|
lhsTableGroup,
|
||||||
null,
|
null,
|
||||||
joinType,
|
sqlAstJoinType,
|
||||||
lockMode,
|
lockMode,
|
||||||
creationState.getSqlAliasBaseManager(),
|
creationState.getSqlAliasBaseManager(),
|
||||||
creationState.getSqlAstCreationState().getSqlExpressionResolver(),
|
creationState.getSqlAstCreationState().getSqlExpressionResolver(),
|
||||||
|
@ -199,7 +201,7 @@ public class SingularAssociationAttributeMapping extends AbstractSingularAttribu
|
||||||
NavigablePath navigablePath,
|
NavigablePath navigablePath,
|
||||||
TableGroup lhs,
|
TableGroup lhs,
|
||||||
String explicitSourceAlias,
|
String explicitSourceAlias,
|
||||||
JoinType joinType,
|
SqlAstJoinType sqlAstJoinType,
|
||||||
LockMode lockMode,
|
LockMode lockMode,
|
||||||
SqlAliasBaseGenerator aliasBaseGenerator,
|
SqlAliasBaseGenerator aliasBaseGenerator,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
@ -212,23 +214,39 @@ public class SingularAssociationAttributeMapping extends AbstractSingularAttribu
|
||||||
this,
|
this,
|
||||||
lockMode,
|
lockMode,
|
||||||
sqlAliasBase,
|
sqlAliasBase,
|
||||||
|
(tableExpression, tableGroup) -> createTableReferenceJoin(
|
||||||
|
tableExpression,
|
||||||
|
sqlAliasBase,
|
||||||
|
tableGroup.getPrimaryTableReference(),
|
||||||
|
false,
|
||||||
|
sqlExpressionResolver,
|
||||||
|
creationContext
|
||||||
|
),
|
||||||
creationContext.getSessionFactory()
|
creationContext.getSessionFactory()
|
||||||
);
|
);
|
||||||
|
|
||||||
applyTableReferences(
|
tableGroupBuilder.applyPrimaryReference(
|
||||||
sqlAliasBase,
|
getEntityMappingType().createPrimaryTableReference(
|
||||||
joinType,
|
sqlAliasBase,
|
||||||
tableGroupBuilder,
|
sqlExpressionResolver,
|
||||||
sqlExpressionResolver,
|
creationContext
|
||||||
creationContext
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// applyTableReferences(
|
||||||
|
// sqlAliasBase,
|
||||||
|
// joinType,
|
||||||
|
// tableGroupBuilder,
|
||||||
|
// sqlExpressionResolver,
|
||||||
|
// creationContext
|
||||||
|
// );
|
||||||
|
|
||||||
getMappedTypeDescriptor().getIdentifierMapping();
|
getMappedTypeDescriptor().getIdentifierMapping();
|
||||||
|
|
||||||
final TableGroup tableGroup = tableGroupBuilder.build();
|
final TableGroup tableGroup = tableGroupBuilder.build();
|
||||||
final TableGroupJoin tableGroupJoin = new TableGroupJoin(
|
final TableGroupJoin tableGroupJoin = new TableGroupJoin(
|
||||||
navigablePath,
|
navigablePath,
|
||||||
joinType,
|
sqlAstJoinType,
|
||||||
tableGroup,
|
tableGroup,
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
@ -238,7 +256,7 @@ public class SingularAssociationAttributeMapping extends AbstractSingularAttribu
|
||||||
final Predicate predicate = foreignKeyDescriptor.generateJoinPredicate(
|
final Predicate predicate = foreignKeyDescriptor.generateJoinPredicate(
|
||||||
lhs,
|
lhs,
|
||||||
tableGroup,
|
tableGroup,
|
||||||
joinType,
|
sqlAstJoinType,
|
||||||
sqlExpressionResolver,
|
sqlExpressionResolver,
|
||||||
creationContext
|
creationContext
|
||||||
);
|
);
|
||||||
|
@ -252,16 +270,42 @@ public class SingularAssociationAttributeMapping extends AbstractSingularAttribu
|
||||||
return sqlAliasStem;
|
return sqlAliasStem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableReference createPrimaryTableReference(
|
||||||
|
SqlAliasBase sqlAliasBase,
|
||||||
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
SqlAstCreationContext creationContext) {
|
||||||
|
return getEntityMappingType().createPrimaryTableReference( sqlAliasBase, sqlExpressionResolver, creationContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableReferenceJoin createTableReferenceJoin(
|
||||||
|
String joinTableExpression,
|
||||||
|
SqlAliasBase sqlAliasBase,
|
||||||
|
TableReference lhs,
|
||||||
|
boolean canUseInnerJoin,
|
||||||
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
SqlAstCreationContext creationContext) {
|
||||||
|
return getEntityMappingType().createTableReferenceJoin(
|
||||||
|
joinTableExpression,
|
||||||
|
sqlAliasBase,
|
||||||
|
lhs,
|
||||||
|
canUseInnerJoin && ! getAttributeMetadataAccess().resolveAttributeMetadata( null ).isNullable(),
|
||||||
|
sqlExpressionResolver,
|
||||||
|
creationContext
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void applyTableReferences(
|
public void applyTableReferences(
|
||||||
SqlAliasBase sqlAliasBase,
|
SqlAliasBase sqlAliasBase,
|
||||||
JoinType baseJoinType,
|
SqlAstJoinType baseSqlAstJoinType,
|
||||||
TableReferenceCollector collector,
|
TableReferenceCollector collector,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
SqlAstCreationContext creationContext) {
|
SqlAstCreationContext creationContext) {
|
||||||
getMappedTypeDescriptor().applyTableReferences(
|
getMappedTypeDescriptor().applyTableReferences(
|
||||||
sqlAliasBase,
|
sqlAliasBase,
|
||||||
baseJoinType,
|
baseSqlAstJoinType,
|
||||||
collector,
|
collector,
|
||||||
sqlExpressionResolver,
|
sqlExpressionResolver,
|
||||||
creationContext
|
creationContext
|
||||||
|
|
|
@ -109,7 +109,7 @@ import org.hibernate.sql.Alias;
|
||||||
import org.hibernate.sql.SelectFragment;
|
import org.hibernate.sql.SelectFragment;
|
||||||
import org.hibernate.sql.SimpleSelect;
|
import org.hibernate.sql.SimpleSelect;
|
||||||
import org.hibernate.sql.Template;
|
import org.hibernate.sql.Template;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
||||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||||
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
||||||
|
@ -2468,10 +2468,69 @@ public abstract class AbstractCollectionPersister
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableReference createPrimaryTableReference(
|
||||||
|
SqlAliasBase sqlAliasBase,
|
||||||
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
SqlAstCreationContext creationContext) {
|
||||||
|
if ( qualifiedTableName != null && ! isOneToMany() ) {
|
||||||
|
return new TableReference(
|
||||||
|
qualifiedTableName,
|
||||||
|
sqlAliasBase.generateNewAlias(),
|
||||||
|
false,
|
||||||
|
getFactory()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableReferenceJoin createTableReferenceJoin(
|
||||||
|
String joinTableExpression,
|
||||||
|
SqlAliasBase sqlAliasBase,
|
||||||
|
TableReference lhs,
|
||||||
|
boolean canUseInnerJoin,
|
||||||
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
SqlAstCreationContext creationContext) {
|
||||||
|
if ( elementPersister == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String entityPrimaryTableName = ( (Joinable) elementPersister ).getTableName();
|
||||||
|
if ( entityPrimaryTableName.equals( joinTableExpression ) ) {
|
||||||
|
assert qualifiedTableName != null;
|
||||||
|
assert lhs.getTableExpression().equals( qualifiedTableName );
|
||||||
|
|
||||||
|
final TableReference tableReference = elementPersister.createPrimaryTableReference( sqlAliasBase, sqlExpressionResolver, creationContext );
|
||||||
|
final SqlAstJoinType sqlAstJoinType = canUseInnerJoin ? SqlAstJoinType.INNER : SqlAstJoinType.LEFT;
|
||||||
|
return new TableReferenceJoin(
|
||||||
|
sqlAstJoinType,
|
||||||
|
tableReference,
|
||||||
|
generateEntityElementJoinPredicate(
|
||||||
|
lhs,
|
||||||
|
tableReference,
|
||||||
|
sqlAstJoinType,
|
||||||
|
sqlExpressionResolver,
|
||||||
|
creationContext
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return elementPersister.createTableReferenceJoin(
|
||||||
|
joinTableExpression,
|
||||||
|
sqlAliasBase,
|
||||||
|
lhs,
|
||||||
|
canUseInnerJoin,
|
||||||
|
sqlExpressionResolver,
|
||||||
|
creationContext
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void applyTableReferences(
|
public void applyTableReferences(
|
||||||
SqlAliasBase sqlAliasBase,
|
SqlAliasBase sqlAliasBase,
|
||||||
JoinType baseJoinType,
|
SqlAstJoinType baseSqlAstJoinType,
|
||||||
TableReferenceCollector collector,
|
TableReferenceCollector collector,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
SqlAstCreationContext creationContext) {
|
SqlAstCreationContext creationContext) {
|
||||||
|
@ -2499,10 +2558,10 @@ public abstract class AbstractCollectionPersister
|
||||||
// entity's primary table
|
// entity's primary table
|
||||||
collector.applyPrimaryJoinProducer(
|
collector.applyPrimaryJoinProducer(
|
||||||
(lhs, rhs) -> new TableReferenceJoin(
|
(lhs, rhs) -> new TableReferenceJoin(
|
||||||
baseJoinType,
|
baseSqlAstJoinType,
|
||||||
rhs,
|
rhs,
|
||||||
generateEntityElementJoinPredicate(
|
generateEntityElementJoinPredicate(
|
||||||
lhs, rhs, baseJoinType, sqlExpressionResolver, creationContext
|
lhs, rhs, baseSqlAstJoinType, sqlExpressionResolver, creationContext
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -2510,7 +2569,7 @@ public abstract class AbstractCollectionPersister
|
||||||
elementPersister.applyTableReferences(
|
elementPersister.applyTableReferences(
|
||||||
sqlAliasBase,
|
sqlAliasBase,
|
||||||
// todo (6.0) : determine the proper join-type to use
|
// todo (6.0) : determine the proper join-type to use
|
||||||
JoinType.LEFT,
|
SqlAstJoinType.LEFT,
|
||||||
collector,
|
collector,
|
||||||
sqlExpressionResolver,
|
sqlExpressionResolver,
|
||||||
creationContext
|
creationContext
|
||||||
|
@ -2523,12 +2582,12 @@ public abstract class AbstractCollectionPersister
|
||||||
|
|
||||||
collector.applyPrimaryJoinProducer(
|
collector.applyPrimaryJoinProducer(
|
||||||
(lhs, rhs) -> new TableReferenceJoin(
|
(lhs, rhs) -> new TableReferenceJoin(
|
||||||
baseJoinType,
|
baseSqlAstJoinType,
|
||||||
rhs,
|
rhs,
|
||||||
generateIndexJoinPredicate(
|
generateIndexJoinPredicate(
|
||||||
lhs,
|
lhs,
|
||||||
rhs,
|
rhs,
|
||||||
JoinType.CROSS,
|
SqlAstJoinType.CROSS,
|
||||||
sqlExpressionResolver,
|
sqlExpressionResolver,
|
||||||
creationContext
|
creationContext
|
||||||
)
|
)
|
||||||
|
@ -2537,7 +2596,7 @@ public abstract class AbstractCollectionPersister
|
||||||
|
|
||||||
contributor.applyTableReferences(
|
contributor.applyTableReferences(
|
||||||
sqlAliasBase,
|
sqlAliasBase,
|
||||||
baseJoinType,
|
baseSqlAstJoinType,
|
||||||
collector,
|
collector,
|
||||||
sqlExpressionResolver,
|
sqlExpressionResolver,
|
||||||
creationContext
|
creationContext
|
||||||
|
@ -2548,7 +2607,7 @@ public abstract class AbstractCollectionPersister
|
||||||
private Predicate generateIndexJoinPredicate(
|
private Predicate generateIndexJoinPredicate(
|
||||||
TableReference lhs,
|
TableReference lhs,
|
||||||
TableReference rhs,
|
TableReference rhs,
|
||||||
JoinType joinType,
|
SqlAstJoinType sqlAstJoinType,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
SqlAstCreationContext creationContext) {
|
SqlAstCreationContext creationContext) {
|
||||||
final CollectionPart indexDescriptor = attributeMapping.getIndexDescriptor();
|
final CollectionPart indexDescriptor = attributeMapping.getIndexDescriptor();
|
||||||
|
@ -2649,7 +2708,7 @@ public abstract class AbstractCollectionPersister
|
||||||
private Predicate generateEntityElementJoinPredicate(
|
private Predicate generateEntityElementJoinPredicate(
|
||||||
TableReference lhs,
|
TableReference lhs,
|
||||||
TableReference rhs,
|
TableReference rhs,
|
||||||
JoinType baseJoinType,
|
SqlAstJoinType baseSqlAstJoinType,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
SqlAstCreationContext creationContext) {
|
SqlAstCreationContext creationContext) {
|
||||||
final SessionFactoryImplementor sessionFactory = creationContext.getSessionFactory();
|
final SessionFactoryImplementor sessionFactory = creationContext.getSessionFactory();
|
||||||
|
|
|
@ -11,7 +11,6 @@ import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
|
@ -26,22 +25,18 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.id.IdentifierGenerator;
|
import org.hibernate.id.IdentifierGenerator;
|
||||||
import org.hibernate.metadata.CollectionMetadata;
|
import org.hibernate.metadata.CollectionMetadata;
|
||||||
import org.hibernate.metamodel.CollectionClassification;
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
import org.hibernate.metamodel.mapping.EntityMappingType;
|
|
||||||
import org.hibernate.metamodel.mapping.ModelPart;
|
|
||||||
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
|
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
|
||||||
import org.hibernate.metamodel.model.domain.NavigableRole;
|
import org.hibernate.metamodel.model.domain.NavigableRole;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.persister.walking.spi.CollectionDefinition;
|
import org.hibernate.persister.walking.spi.CollectionDefinition;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasStemHelper;
|
|
||||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||||
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
||||||
import org.hibernate.sql.ast.tree.from.TableReferenceCollector;
|
import org.hibernate.sql.ast.tree.from.TableReferenceCollector;
|
||||||
import org.hibernate.sql.ast.tree.from.TableReferenceContributor;
|
import org.hibernate.sql.ast.tree.from.TableReferenceContributor;
|
||||||
import org.hibernate.type.CollectionType;
|
import org.hibernate.type.CollectionType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A strategy for persisting a collection role. Defines a contract between
|
* A strategy for persisting a collection role. Defines a contract between
|
||||||
|
@ -384,7 +379,7 @@ public interface CollectionPersister extends CollectionDefinition, TableReferenc
|
||||||
@Override
|
@Override
|
||||||
default void applyTableReferences(
|
default void applyTableReferences(
|
||||||
SqlAliasBase sqlAliasBase,
|
SqlAliasBase sqlAliasBase,
|
||||||
JoinType baseJoinType,
|
SqlAstJoinType baseSqlAstJoinType,
|
||||||
TableReferenceCollector collector,
|
TableReferenceCollector collector,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
SqlAstCreationContext creationContext) {
|
SqlAstCreationContext creationContext) {
|
||||||
|
|
|
@ -568,5 +568,4 @@ public class OneToManyPersister extends AbstractCollectionPersister {
|
||||||
public FilterAliasGenerator getFilterAliasGenerator(String rootAlias) {
|
public FilterAliasGenerator getFilterAliasGenerator(String rootAlias) {
|
||||||
return getElementPersister().getFilterAliasGenerator( rootAlias );
|
return getElementPersister().getFilterAliasGenerator( rootAlias );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,6 +173,7 @@ import org.hibernate.sql.SimpleSelect;
|
||||||
import org.hibernate.sql.Template;
|
import org.hibernate.sql.Template;
|
||||||
import org.hibernate.sql.Update;
|
import org.hibernate.sql.Update;
|
||||||
import org.hibernate.sql.ast.Clause;
|
import org.hibernate.sql.ast.Clause;
|
||||||
|
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasStemHelper;
|
import org.hibernate.sql.ast.spi.SqlAliasStemHelper;
|
||||||
|
@ -1216,7 +1217,7 @@ public abstract class AbstractEntityPersister
|
||||||
public TableGroup createRootTableGroup(
|
public TableGroup createRootTableGroup(
|
||||||
NavigablePath navigablePath,
|
NavigablePath navigablePath,
|
||||||
String explicitSourceAlias,
|
String explicitSourceAlias,
|
||||||
org.hibernate.sql.ast.JoinType tableReferenceJoinType,
|
boolean canUseInnerJoins,
|
||||||
LockMode lockMode,
|
LockMode lockMode,
|
||||||
SqlAliasBaseGenerator aliasBaseGenerator,
|
SqlAliasBaseGenerator aliasBaseGenerator,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
@ -1229,24 +1230,104 @@ public abstract class AbstractEntityPersister
|
||||||
this,
|
this,
|
||||||
lockMode,
|
lockMode,
|
||||||
sqlAliasBase,
|
sqlAliasBase,
|
||||||
|
(tableExpression, tableGroup) -> {
|
||||||
|
for ( int i = 0; i < getSubclassTableSpan(); i++ ) {
|
||||||
|
final String subclassTableName = getSubclassTableName( i );
|
||||||
|
if ( subclassTableName.equals( tableExpression ) ) {
|
||||||
|
final boolean isNullableTable = isNullableSubclassTable( i );
|
||||||
|
final TableReference joinedTableReference = new TableReference(
|
||||||
|
tableExpression,
|
||||||
|
sqlAliasBase.generateNewAlias(),
|
||||||
|
isNullableTable,
|
||||||
|
getFactory()
|
||||||
|
);
|
||||||
|
|
||||||
|
return new TableReferenceJoin(
|
||||||
|
determineSubclassTableJoinType(
|
||||||
|
i,
|
||||||
|
canUseInnerJoins,
|
||||||
|
true,
|
||||||
|
Collections.emptySet()
|
||||||
|
),
|
||||||
|
joinedTableReference,
|
||||||
|
generateJoinPredicate(
|
||||||
|
tableGroup.getPrimaryTableReference(),
|
||||||
|
joinedTableReference,
|
||||||
|
i,
|
||||||
|
sqlExpressionResolver
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
},
|
||||||
creationContext.getSessionFactory()
|
creationContext.getSessionFactory()
|
||||||
);
|
);
|
||||||
|
|
||||||
applyTableReferences(
|
|
||||||
sqlAliasBase,
|
builder.applyPrimaryReference(
|
||||||
tableReferenceJoinType,
|
createPrimaryTableReference(
|
||||||
builder,
|
sqlAliasBase,
|
||||||
sqlExpressionResolver,
|
sqlExpressionResolver,
|
||||||
creationContext
|
creationContext
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// applyTableReferences(
|
||||||
|
// sqlAliasBase,
|
||||||
|
// tableReferenceJoinType,
|
||||||
|
// builder,
|
||||||
|
// sqlExpressionResolver,
|
||||||
|
// creationContext
|
||||||
|
// );
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TableReference resolvePrimaryTableReference(
|
@Override
|
||||||
|
public TableReference createPrimaryTableReference(
|
||||||
SqlAliasBase sqlAliasBase,
|
SqlAliasBase sqlAliasBase,
|
||||||
SqlExpressionResolver sqlExpressionResolver) {
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
// todo (6.0) : temporary
|
SqlAstCreationContext creationContext) {
|
||||||
|
return resolvePrimaryTableReference( sqlAliasBase );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableReferenceJoin createTableReferenceJoin(
|
||||||
|
String joinTableExpression,
|
||||||
|
SqlAliasBase sqlAliasBase,
|
||||||
|
TableReference lhs,
|
||||||
|
boolean canUseInnerJoin,
|
||||||
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
SqlAstCreationContext creationContext) {
|
||||||
|
for ( int i = 1; i < getSubclassTableSpan(); i++ ) {
|
||||||
|
final String subclassTableName = getSubclassTableName( i );
|
||||||
|
if ( subclassTableName.equals( joinTableExpression ) ) {
|
||||||
|
final TableReference joinedTableReference = new TableReference(
|
||||||
|
joinTableExpression,
|
||||||
|
sqlAliasBase.generateNewAlias(),
|
||||||
|
isNullableSubclassTable( i ),
|
||||||
|
getFactory()
|
||||||
|
);
|
||||||
|
|
||||||
|
return new TableReferenceJoin(
|
||||||
|
canUseInnerJoin ? SqlAstJoinType.INNER : SqlAstJoinType.LEFT,
|
||||||
|
joinedTableReference,
|
||||||
|
generateJoinPredicate(
|
||||||
|
lhs,
|
||||||
|
joinedTableReference,
|
||||||
|
i,
|
||||||
|
sqlExpressionResolver
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected TableReference resolvePrimaryTableReference(SqlAliasBase sqlAliasBase) {
|
||||||
return new TableReference(
|
return new TableReference(
|
||||||
getRootTableName(),
|
getRootTableName(),
|
||||||
sqlAliasBase.generateNewAlias(),
|
sqlAliasBase.generateNewAlias(),
|
||||||
|
@ -1258,14 +1339,11 @@ public abstract class AbstractEntityPersister
|
||||||
@Override
|
@Override
|
||||||
public void applyTableReferences(
|
public void applyTableReferences(
|
||||||
SqlAliasBase sqlAliasBase,
|
SqlAliasBase sqlAliasBase,
|
||||||
org.hibernate.sql.ast.JoinType baseJoinType,
|
SqlAstJoinType baseSqlAstJoinType,
|
||||||
TableReferenceCollector collector,
|
TableReferenceCollector collector,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
SqlAstCreationContext creationContext) {
|
SqlAstCreationContext creationContext) {
|
||||||
final TableReference primaryTableReference = resolvePrimaryTableReference(
|
final TableReference primaryTableReference = resolvePrimaryTableReference( sqlAliasBase );
|
||||||
sqlAliasBase,
|
|
||||||
sqlExpressionResolver
|
|
||||||
);
|
|
||||||
|
|
||||||
collector.applyPrimaryReference( primaryTableReference );
|
collector.applyPrimaryReference( primaryTableReference );
|
||||||
|
|
||||||
|
@ -1285,7 +1363,7 @@ public abstract class AbstractEntityPersister
|
||||||
protected TableReferenceJoin createTableReferenceJoin(
|
protected TableReferenceJoin createTableReferenceJoin(
|
||||||
int subClassTablePosition,
|
int subClassTablePosition,
|
||||||
TableReference rootTableReference,
|
TableReference rootTableReference,
|
||||||
org.hibernate.sql.ast.JoinType joinType,
|
SqlAstJoinType sqlAstJoinType,
|
||||||
SqlAliasBase sqlAliasBase,
|
SqlAliasBase sqlAliasBase,
|
||||||
SqlExpressionResolver sqlExpressionResolver) {
|
SqlExpressionResolver sqlExpressionResolver) {
|
||||||
final boolean nullable = isNullableSubclassTable( subClassTablePosition );
|
final boolean nullable = isNullableSubclassTable( subClassTablePosition );
|
||||||
|
@ -1298,7 +1376,7 @@ public abstract class AbstractEntityPersister
|
||||||
);
|
);
|
||||||
|
|
||||||
return new TableReferenceJoin(
|
return new TableReferenceJoin(
|
||||||
nullable ? org.hibernate.sql.ast.JoinType.LEFT : joinType,
|
nullable ? SqlAstJoinType.LEFT : sqlAstJoinType,
|
||||||
joinedTableReference,
|
joinedTableReference,
|
||||||
generateJoinPredicate( rootTableReference, joinedTableReference, subClassTablePosition, sqlExpressionResolver )
|
generateJoinPredicate( rootTableReference, joinedTableReference, subClassTablePosition, sqlExpressionResolver )
|
||||||
);
|
);
|
||||||
|
@ -4091,7 +4169,7 @@ public abstract class AbstractEntityPersister
|
||||||
return join;
|
return join;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected org.hibernate.sql.ast.JoinType determineSubclassTableJoinType(
|
protected SqlAstJoinType determineSubclassTableJoinType(
|
||||||
int subclassTableNumber,
|
int subclassTableNumber,
|
||||||
boolean canInnerJoin,
|
boolean canInnerJoin,
|
||||||
boolean includeSubclasses,
|
boolean includeSubclasses,
|
||||||
|
@ -4102,7 +4180,7 @@ public abstract class AbstractEntityPersister
|
||||||
&& !isNullableTable( subclassTableNumber );
|
&& !isNullableTable( subclassTableNumber );
|
||||||
// the table is either this persister's driving table or (one of) its super class persister's driving
|
// the table is either this persister's driving table or (one of) its super class persister's driving
|
||||||
// tables which can be inner joined as long as the `shouldInnerJoin` condition resolves to true
|
// tables which can be inner joined as long as the `shouldInnerJoin` condition resolves to true
|
||||||
return shouldInnerJoin ? org.hibernate.sql.ast.JoinType.INNER : org.hibernate.sql.ast.JoinType.LEFT;
|
return shouldInnerJoin ? SqlAstJoinType.INNER : SqlAstJoinType.LEFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise we have a subclass table and need to look a little deeper...
|
// otherwise we have a subclass table and need to look a little deeper...
|
||||||
|
@ -4112,15 +4190,15 @@ public abstract class AbstractEntityPersister
|
||||||
// so we give TREAT-AS higher precedence...
|
// so we give TREAT-AS higher precedence...
|
||||||
|
|
||||||
if ( isSubclassTableIndicatedByTreatAsDeclarations( subclassTableNumber, treatAsDeclarations ) ) {
|
if ( isSubclassTableIndicatedByTreatAsDeclarations( subclassTableNumber, treatAsDeclarations ) ) {
|
||||||
return org.hibernate.sql.ast.JoinType.INNER;
|
return SqlAstJoinType.INNER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( includeSubclasses
|
if ( includeSubclasses
|
||||||
&& !isSubclassTableSequentialSelect( subclassTableNumber )
|
&& !isSubclassTableSequentialSelect( subclassTableNumber )
|
||||||
&& !isSubclassTableLazy( subclassTableNumber ) ) {
|
&& !isSubclassTableLazy( subclassTableNumber ) ) {
|
||||||
return org.hibernate.sql.ast.JoinType.LEFT;
|
return SqlAstJoinType.LEFT;
|
||||||
}
|
}
|
||||||
return org.hibernate.sql.ast.JoinType.INNER;
|
return SqlAstJoinType.INNER;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected JoinType determineSubclassTableJoinType(
|
protected JoinType determineSubclassTableJoinType(
|
||||||
|
|
|
@ -12,9 +12,11 @@ import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.TreeMap;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
@ -59,7 +61,6 @@ import org.hibernate.sql.CaseFragment;
|
||||||
import org.hibernate.sql.InFragment;
|
import org.hibernate.sql.InFragment;
|
||||||
import org.hibernate.sql.Insert;
|
import org.hibernate.sql.Insert;
|
||||||
import org.hibernate.sql.SelectFragment;
|
import org.hibernate.sql.SelectFragment;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
||||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||||
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
||||||
|
@ -531,7 +532,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
if ( persistentClass.isPolymorphic() ) {
|
if ( persistentClass.isPolymorphic() ) {
|
||||||
subclassesByDiscriminatorValue.put( discriminatorValue, getEntityName() );
|
subclassesByDiscriminatorValue.put( discriminatorValue, getEntityName() );
|
||||||
|
|
||||||
discriminatorValuesByTableName = new HashMap<>( subclassSpan + 1 );
|
discriminatorValuesByTableName = new LinkedHashMap<>( subclassSpan + 1 );
|
||||||
subclassNameByTableName = new HashMap<>( subclassSpan + 1);
|
subclassNameByTableName = new HashMap<>( subclassSpan + 1);
|
||||||
discriminatorValuesByTableName.put( persistentClass.getTable().getName(), discriminatorSQLString);
|
discriminatorValuesByTableName.put( persistentClass.getTable().getName(), discriminatorSQLString);
|
||||||
discriminatorValues = new String[subclassSpan];
|
discriminatorValues = new String[subclassSpan];
|
||||||
|
@ -1216,7 +1217,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
public TableGroup createRootTableGroup(
|
public TableGroup createRootTableGroup(
|
||||||
NavigablePath navigablePath,
|
NavigablePath navigablePath,
|
||||||
String explicitSourceAlias,
|
String explicitSourceAlias,
|
||||||
JoinType tableReferenceJoinType,
|
boolean canUseInnerJoins,
|
||||||
LockMode lockMode,
|
LockMode lockMode,
|
||||||
SqlAliasBaseGenerator aliasBaseGenerator,
|
SqlAliasBaseGenerator aliasBaseGenerator,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
@ -1225,7 +1226,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
return super.createRootTableGroup(
|
return super.createRootTableGroup(
|
||||||
navigablePath,
|
navigablePath,
|
||||||
explicitSourceAlias,
|
explicitSourceAlias,
|
||||||
tableReferenceJoinType,
|
canUseInnerJoins,
|
||||||
lockMode,
|
lockMode,
|
||||||
aliasBaseGenerator,
|
aliasBaseGenerator,
|
||||||
sqlExpressionResolver,
|
sqlExpressionResolver,
|
||||||
|
@ -1279,25 +1280,30 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
CaseSearchedExpressionInfo info = new CaseSearchedExpressionInfo();
|
CaseSearchedExpressionInfo info = new CaseSearchedExpressionInfo();
|
||||||
|
|
||||||
final TableReference primaryTableReference = entityTableGroup.getPrimaryTableReference();
|
final TableReference primaryTableReference = entityTableGroup.getPrimaryTableReference();
|
||||||
final List<TableReferenceJoin> tableReferenceJoins = entityTableGroup.getTableReferenceJoins();
|
|
||||||
final BasicType discriminatorType = (BasicType) getDiscriminatorType();
|
final BasicType discriminatorType = (BasicType) getDiscriminatorType();
|
||||||
final CaseSearchedExpression caseSearchedExpression = new CaseSearchedExpression( discriminatorType );
|
final CaseSearchedExpression caseSearchedExpression = new CaseSearchedExpression( discriminatorType );
|
||||||
|
|
||||||
for ( int i = tableReferenceJoins.size() - 1; i >= 0; i-- ) {
|
discriminatorValuesByTableName.forEach(
|
||||||
final TableReferenceJoin tableReferenceJoin = tableReferenceJoins.get( i );
|
(tableName, discriminatorValue) -> {
|
||||||
final TableReference joinedTableReference = tableReferenceJoin.getJoinedTableReference();
|
if ( ! primaryTableReference.getTableExpression().equals( tableName ) ) {
|
||||||
if ( discriminatorValuesByTableName.containsKey( joinedTableReference.getTableExpression() ) ) {
|
TableReference tableReference = entityTableGroup.getTableReference( tableName );
|
||||||
final ColumnReference identifierColumnReference = getIdentifierColumnReference(
|
if ( tableReference == null ) {
|
||||||
joinedTableReference );
|
// we have not yet created a TableReference for this sub-class table, but we need to because
|
||||||
info.columnReferences.add( identifierColumnReference );
|
// it has a discriminator value associated with it
|
||||||
addWhen(
|
tableReference = entityTableGroup.resolveTableReference( tableName );
|
||||||
caseSearchedExpression,
|
}
|
||||||
joinedTableReference,
|
|
||||||
identifierColumnReference,
|
final ColumnReference identifierColumnReference = getIdentifierColumnReference( tableReference );
|
||||||
discriminatorType
|
info.columnReferences.add( identifierColumnReference );
|
||||||
);
|
addWhen(
|
||||||
}
|
caseSearchedExpression,
|
||||||
}
|
tableReference,
|
||||||
|
identifierColumnReference,
|
||||||
|
discriminatorType
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
addWhen(
|
addWhen(
|
||||||
caseSearchedExpression,
|
caseSearchedExpression,
|
||||||
|
|
|
@ -46,7 +46,6 @@ import org.hibernate.query.NavigablePath;
|
||||||
import org.hibernate.sql.InFragment;
|
import org.hibernate.sql.InFragment;
|
||||||
import org.hibernate.sql.Insert;
|
import org.hibernate.sql.Insert;
|
||||||
import org.hibernate.sql.SelectFragment;
|
import org.hibernate.sql.SelectFragment;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
||||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||||
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
||||||
|
@ -882,7 +881,7 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
||||||
public TableGroup createRootTableGroup(
|
public TableGroup createRootTableGroup(
|
||||||
NavigablePath navigablePath,
|
NavigablePath navigablePath,
|
||||||
String explicitSourceAlias,
|
String explicitSourceAlias,
|
||||||
JoinType tableReferenceJoinType,
|
boolean canUseInnerJoins,
|
||||||
LockMode lockMode,
|
LockMode lockMode,
|
||||||
SqlAliasBaseGenerator aliasBaseGenerator,
|
SqlAliasBaseGenerator aliasBaseGenerator,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
@ -891,7 +890,7 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
||||||
final TableGroup tableGroup = super.createRootTableGroup(
|
final TableGroup tableGroup = super.createRootTableGroup(
|
||||||
navigablePath,
|
navigablePath,
|
||||||
explicitSourceAlias,
|
explicitSourceAlias,
|
||||||
tableReferenceJoinType,
|
canUseInnerJoins,
|
||||||
lockMode,
|
lockMode,
|
||||||
aliasBaseGenerator,
|
aliasBaseGenerator,
|
||||||
sqlExpressionResolver,
|
sqlExpressionResolver,
|
||||||
|
|
|
@ -47,8 +47,6 @@ import org.hibernate.persister.spi.PersisterCreationContext;
|
||||||
import org.hibernate.property.access.spi.Setter;
|
import org.hibernate.property.access.spi.Setter;
|
||||||
import org.hibernate.query.NavigablePath;
|
import org.hibernate.query.NavigablePath;
|
||||||
import org.hibernate.sql.SelectFragment;
|
import org.hibernate.sql.SelectFragment;
|
||||||
import org.hibernate.sql.SimpleSelect;
|
|
||||||
import org.hibernate.sql.ast.JoinType;
|
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
||||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||||
|
@ -233,7 +231,7 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
public TableGroup createRootTableGroup(
|
public TableGroup createRootTableGroup(
|
||||||
NavigablePath navigablePath,
|
NavigablePath navigablePath,
|
||||||
String explicitSourceAlias,
|
String explicitSourceAlias,
|
||||||
JoinType tableReferenceJoinType,
|
boolean canUseInnerJoins,
|
||||||
LockMode lockMode,
|
LockMode lockMode,
|
||||||
SqlAliasBaseGenerator aliasBaseGenerator,
|
SqlAliasBaseGenerator aliasBaseGenerator,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
|
|
@ -27,19 +27,18 @@ import org.hibernate.query.sqm.tree.predicate.SqmWhereClause;
|
||||||
import org.hibernate.query.sqm.tree.select.SqmSelectClause;
|
import org.hibernate.query.sqm.tree.select.SqmSelectClause;
|
||||||
import org.hibernate.query.sqm.tree.update.SqmAssignment;
|
import org.hibernate.query.sqm.tree.update.SqmAssignment;
|
||||||
import org.hibernate.query.sqm.tree.update.SqmSetClause;
|
import org.hibernate.query.sqm.tree.update.SqmSetClause;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
|
||||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||||
import org.hibernate.sql.ast.spi.SqlAstCreationState;
|
import org.hibernate.sql.ast.spi.SqlAstCreationState;
|
||||||
import org.hibernate.sql.ast.spi.SqlAstProcessingState;
|
import org.hibernate.sql.ast.spi.SqlAstProcessingState;
|
||||||
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
||||||
import org.hibernate.sql.ast.tree.expression.ColumnReference;
|
import org.hibernate.sql.ast.tree.expression.ColumnReference;
|
||||||
import org.hibernate.sql.ast.tree.expression.Expression;
|
import org.hibernate.sql.ast.tree.expression.Expression;
|
||||||
|
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
|
||||||
import org.hibernate.sql.ast.tree.from.TableGroup;
|
import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||||
import org.hibernate.sql.ast.tree.predicate.Predicate;
|
import org.hibernate.sql.ast.tree.predicate.Predicate;
|
||||||
import org.hibernate.sql.ast.tree.select.QuerySpec;
|
import org.hibernate.sql.ast.tree.select.QuerySpec;
|
||||||
import org.hibernate.sql.ast.tree.update.Assignable;
|
import org.hibernate.sql.ast.tree.update.Assignable;
|
||||||
import org.hibernate.sql.ast.tree.update.Assignment;
|
import org.hibernate.sql.ast.tree.update.Assignment;
|
||||||
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
|
|
||||||
import org.hibernate.sql.results.graph.DomainResultCreationState;
|
import org.hibernate.sql.results.graph.DomainResultCreationState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -80,7 +79,7 @@ public class MultiTableSqmMutationConverter extends BaseSqmToSqlAstConverter imp
|
||||||
this.mutatingTableGroup = mutatingEntityDescriptor.createRootTableGroup(
|
this.mutatingTableGroup = mutatingEntityDescriptor.createRootTableGroup(
|
||||||
navigablePath,
|
navigablePath,
|
||||||
null,
|
null,
|
||||||
JoinType.LEFT,
|
true,
|
||||||
LockMode.PESSIMISTIC_WRITE,
|
LockMode.PESSIMISTIC_WRITE,
|
||||||
getSqlAliasBaseGenerator(),
|
getSqlAliasBaseGenerator(),
|
||||||
getSqlExpressionResolver(),
|
getSqlExpressionResolver(),
|
||||||
|
@ -89,9 +88,6 @@ public class MultiTableSqmMutationConverter extends BaseSqmToSqlAstConverter imp
|
||||||
creationContext.getSessionFactory()
|
creationContext.getSessionFactory()
|
||||||
);
|
);
|
||||||
|
|
||||||
// because this is a multi-table update, here we expect multiple TableReferences
|
|
||||||
assert !mutatingTableGroup.getTableReferenceJoins().isEmpty();
|
|
||||||
|
|
||||||
getFromClauseAccess().registerTableGroup( navigablePath, mutatingTableGroup );
|
getFromClauseAccess().registerTableGroup( navigablePath, mutatingTableGroup );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -166,6 +166,7 @@ public final class ExecuteWithIdTableHelper {
|
||||||
idTableReference,
|
idTableReference,
|
||||||
Collections.emptyList(),
|
Collections.emptyList(),
|
||||||
null,
|
null,
|
||||||
|
null,
|
||||||
executionContext.getSession().getFactory()
|
executionContext.getSession().getFactory()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ public final class ExecuteWithoutIdTableHelper {
|
||||||
rootTableReference,
|
rootTableReference,
|
||||||
Collections.emptyList(),
|
Collections.emptyList(),
|
||||||
null,
|
null,
|
||||||
|
null,
|
||||||
sessionFactory
|
sessionFactory
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ import org.hibernate.query.sqm.tree.select.SqmSortSpecification;
|
||||||
import org.hibernate.query.sqm.tree.select.SqmSubQuery;
|
import org.hibernate.query.sqm.tree.select.SqmSubQuery;
|
||||||
import org.hibernate.query.sqm.tree.update.SqmUpdateStatement;
|
import org.hibernate.query.sqm.tree.update.SqmUpdateStatement;
|
||||||
import org.hibernate.sql.ast.Clause;
|
import org.hibernate.sql.ast.Clause;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||||
import org.hibernate.sql.ast.spi.FromClauseAccess;
|
import org.hibernate.sql.ast.spi.FromClauseAccess;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBaseManager;
|
import org.hibernate.sql.ast.spi.SqlAliasBaseManager;
|
||||||
|
@ -487,7 +487,7 @@ public abstract class BaseSqmToSqlAstConverter
|
||||||
final TableGroup tableGroup = entityDescriptor.createRootTableGroup(
|
final TableGroup tableGroup = entityDescriptor.createRootTableGroup(
|
||||||
sqmRoot.getNavigablePath(),
|
sqmRoot.getNavigablePath(),
|
||||||
sqmRoot.getExplicitAlias(),
|
sqmRoot.getExplicitAlias(),
|
||||||
JoinType.INNER,
|
true,
|
||||||
LockMode.NONE,
|
LockMode.NONE,
|
||||||
sqlAliasBaseManager,
|
sqlAliasBaseManager,
|
||||||
getSqlExpressionResolver(),
|
getSqlExpressionResolver(),
|
||||||
|
@ -573,7 +573,7 @@ public abstract class BaseSqmToSqlAstConverter
|
||||||
final TableGroup tableGroup = entityDescriptor.createRootTableGroup(
|
final TableGroup tableGroup = entityDescriptor.createRootTableGroup(
|
||||||
sqmJoin.getNavigablePath(),
|
sqmJoin.getNavigablePath(),
|
||||||
sqmJoin.getExplicitAlias(),
|
sqmJoin.getExplicitAlias(),
|
||||||
JoinType.CROSS,
|
true,
|
||||||
determineLockMode( sqmJoin.getExplicitAlias() ),
|
determineLockMode( sqmJoin.getExplicitAlias() ),
|
||||||
sqlAliasBaseManager,
|
sqlAliasBaseManager,
|
||||||
getSqlExpressionResolver(),
|
getSqlExpressionResolver(),
|
||||||
|
@ -583,7 +583,7 @@ public abstract class BaseSqmToSqlAstConverter
|
||||||
|
|
||||||
final TableGroupJoin tableGroupJoin = new TableGroupJoin(
|
final TableGroupJoin tableGroupJoin = new TableGroupJoin(
|
||||||
sqmJoin.getNavigablePath(),
|
sqmJoin.getNavigablePath(),
|
||||||
JoinType.CROSS,
|
SqlAstJoinType.CROSS,
|
||||||
tableGroup
|
tableGroup
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -601,7 +601,7 @@ public abstract class BaseSqmToSqlAstConverter
|
||||||
final TableGroup tableGroup = entityDescriptor.createRootTableGroup(
|
final TableGroup tableGroup = entityDescriptor.createRootTableGroup(
|
||||||
sqmJoin.getNavigablePath(),
|
sqmJoin.getNavigablePath(),
|
||||||
sqmJoin.getExplicitAlias(),
|
sqmJoin.getExplicitAlias(),
|
||||||
sqmJoin.getSqmJoinType().getCorrespondingSqlJoinType(),
|
true,
|
||||||
determineLockMode( sqmJoin.getExplicitAlias() ),
|
determineLockMode( sqmJoin.getExplicitAlias() ),
|
||||||
sqlAliasBaseManager,
|
sqlAliasBaseManager,
|
||||||
getSqlExpressionResolver(),
|
getSqlExpressionResolver(),
|
||||||
|
@ -651,7 +651,7 @@ public abstract class BaseSqmToSqlAstConverter
|
||||||
joinedPath.getNavigablePath(),
|
joinedPath.getNavigablePath(),
|
||||||
tableGroup,
|
tableGroup,
|
||||||
null,
|
null,
|
||||||
tableGroup.isInnerJoinPossible() ? JoinType.INNER : JoinType.LEFT,
|
tableGroup.isInnerJoinPossible() ? SqlAstJoinType.INNER : SqlAstJoinType.LEFT,
|
||||||
null,
|
null,
|
||||||
sqlAliasBaseManager,
|
sqlAliasBaseManager,
|
||||||
getSqlExpressionResolver(),
|
getSqlExpressionResolver(),
|
||||||
|
|
|
@ -21,7 +21,6 @@ import org.hibernate.query.sqm.tree.cte.SqmCteStatement;
|
||||||
import org.hibernate.query.sqm.tree.delete.SqmDeleteStatement;
|
import org.hibernate.query.sqm.tree.delete.SqmDeleteStatement;
|
||||||
import org.hibernate.query.sqm.tree.predicate.SqmWhereClause;
|
import org.hibernate.query.sqm.tree.predicate.SqmWhereClause;
|
||||||
import org.hibernate.sql.ast.Clause;
|
import org.hibernate.sql.ast.Clause;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
|
||||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||||
import org.hibernate.sql.ast.spi.SqlAstTreeHelper;
|
import org.hibernate.sql.ast.spi.SqlAstTreeHelper;
|
||||||
import org.hibernate.sql.ast.tree.cte.CteStatement;
|
import org.hibernate.sql.ast.tree.cte.CteStatement;
|
||||||
|
@ -82,7 +81,7 @@ public class StandardSqmDeleteTranslator
|
||||||
final TableGroup rootTableGroup = entityDescriptor.createRootTableGroup(
|
final TableGroup rootTableGroup = entityDescriptor.createRootTableGroup(
|
||||||
rootPath,
|
rootPath,
|
||||||
null,
|
null,
|
||||||
JoinType.LEFT,
|
false,
|
||||||
LockMode.WRITE,
|
LockMode.WRITE,
|
||||||
stem -> getSqlAliasBaseGenerator().createSqlAliasBase( stem ),
|
stem -> getSqlAliasBaseGenerator().createSqlAliasBase( stem ),
|
||||||
getSqlExpressionResolver(),
|
getSqlExpressionResolver(),
|
||||||
|
|
|
@ -18,7 +18,6 @@ import org.hibernate.query.sqm.sql.SqmInsertSelectTranslation;
|
||||||
import org.hibernate.query.sqm.sql.SqmInsertSelectTranslator;
|
import org.hibernate.query.sqm.sql.SqmInsertSelectTranslator;
|
||||||
import org.hibernate.query.sqm.tree.cte.SqmCteStatement;
|
import org.hibernate.query.sqm.tree.cte.SqmCteStatement;
|
||||||
import org.hibernate.query.sqm.tree.insert.SqmInsertSelectStatement;
|
import org.hibernate.query.sqm.tree.insert.SqmInsertSelectStatement;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
|
||||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||||
import org.hibernate.sql.ast.tree.cte.CteStatement;
|
import org.hibernate.sql.ast.tree.cte.CteStatement;
|
||||||
import org.hibernate.sql.ast.tree.from.TableGroup;
|
import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||||
|
@ -69,7 +68,7 @@ public class StandardSqmInsertSelectTranslator
|
||||||
final TableGroup rootTableGroup = entityDescriptor.createRootTableGroup(
|
final TableGroup rootTableGroup = entityDescriptor.createRootTableGroup(
|
||||||
rootPath,
|
rootPath,
|
||||||
null,
|
null,
|
||||||
JoinType.LEFT,
|
false,
|
||||||
LockMode.WRITE,
|
LockMode.WRITE,
|
||||||
stem -> getSqlAliasBaseGenerator().createSqlAliasBase( stem ),
|
stem -> getSqlAliasBaseGenerator().createSqlAliasBase( stem ),
|
||||||
getSqlExpressionResolver(),
|
getSqlExpressionResolver(),
|
||||||
|
|
|
@ -43,7 +43,7 @@ import org.hibernate.query.sqm.tree.select.SqmDynamicInstantiationTarget;
|
||||||
import org.hibernate.query.sqm.tree.select.SqmQuerySpec;
|
import org.hibernate.query.sqm.tree.select.SqmQuerySpec;
|
||||||
import org.hibernate.query.sqm.tree.select.SqmSelectStatement;
|
import org.hibernate.query.sqm.tree.select.SqmSelectStatement;
|
||||||
import org.hibernate.query.sqm.tree.select.SqmSelection;
|
import org.hibernate.query.sqm.tree.select.SqmSelection;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||||
import org.hibernate.sql.ast.spi.FromClauseAccess;
|
import org.hibernate.sql.ast.spi.FromClauseAccess;
|
||||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||||
import org.hibernate.sql.ast.spi.SqlAstCreationState;
|
import org.hibernate.sql.ast.spi.SqlAstCreationState;
|
||||||
|
@ -299,7 +299,7 @@ public class StandardSqmSelectTranslator
|
||||||
fetchablePath,
|
fetchablePath,
|
||||||
lhs,
|
lhs,
|
||||||
alias,
|
alias,
|
||||||
JoinType.LEFT,
|
SqlAstJoinType.LEFT,
|
||||||
LockMode.NONE,
|
LockMode.NONE,
|
||||||
getSqlAliasBaseManager(),
|
getSqlAliasBaseManager(),
|
||||||
getSqlExpressionResolver(),
|
getSqlExpressionResolver(),
|
||||||
|
|
|
@ -29,7 +29,6 @@ import org.hibernate.query.sqm.tree.update.SqmAssignment;
|
||||||
import org.hibernate.query.sqm.tree.update.SqmSetClause;
|
import org.hibernate.query.sqm.tree.update.SqmSetClause;
|
||||||
import org.hibernate.query.sqm.tree.update.SqmUpdateStatement;
|
import org.hibernate.query.sqm.tree.update.SqmUpdateStatement;
|
||||||
import org.hibernate.sql.ast.Clause;
|
import org.hibernate.sql.ast.Clause;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
|
||||||
import org.hibernate.sql.ast.SqlTreeCreationLogger;
|
import org.hibernate.sql.ast.SqlTreeCreationLogger;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
||||||
|
@ -39,12 +38,12 @@ import org.hibernate.sql.ast.spi.SqlAstTreeHelper;
|
||||||
import org.hibernate.sql.ast.tree.cte.CteStatement;
|
import org.hibernate.sql.ast.tree.cte.CteStatement;
|
||||||
import org.hibernate.sql.ast.tree.expression.ColumnReference;
|
import org.hibernate.sql.ast.tree.expression.ColumnReference;
|
||||||
import org.hibernate.sql.ast.tree.expression.Expression;
|
import org.hibernate.sql.ast.tree.expression.Expression;
|
||||||
|
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
|
||||||
import org.hibernate.sql.ast.tree.from.TableGroup;
|
import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||||
import org.hibernate.sql.ast.tree.predicate.Predicate;
|
import org.hibernate.sql.ast.tree.predicate.Predicate;
|
||||||
import org.hibernate.sql.ast.tree.update.Assignment;
|
import org.hibernate.sql.ast.tree.update.Assignment;
|
||||||
import org.hibernate.sql.ast.tree.update.UpdateStatement;
|
import org.hibernate.sql.ast.tree.update.UpdateStatement;
|
||||||
import org.hibernate.sql.exec.internal.JdbcParameterImpl;
|
import org.hibernate.sql.exec.internal.JdbcParameterImpl;
|
||||||
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
|
|
||||||
import org.hibernate.type.spi.TypeConfiguration;
|
import org.hibernate.type.spi.TypeConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -96,7 +95,7 @@ public class StandardSqmUpdateTranslator
|
||||||
final TableGroup rootTableGroup = entityDescriptor.createRootTableGroup(
|
final TableGroup rootTableGroup = entityDescriptor.createRootTableGroup(
|
||||||
rootPath,
|
rootPath,
|
||||||
null,
|
null,
|
||||||
JoinType.LEFT,
|
false,
|
||||||
LockMode.WRITE,
|
LockMode.WRITE,
|
||||||
getSqlAliasBaseGenerator(),
|
getSqlAliasBaseGenerator(),
|
||||||
getSqlExpressionResolver(),
|
getSqlExpressionResolver(),
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.query.sqm.tree;
|
package org.hibernate.query.sqm.tree;
|
||||||
|
|
||||||
import org.hibernate.sql.ast.JoinType;
|
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a canonical join type.
|
* Represents a canonical join type.
|
||||||
|
@ -24,38 +24,38 @@ public enum SqmJoinType {
|
||||||
/**
|
/**
|
||||||
* Represents an inner join.
|
* Represents an inner join.
|
||||||
*/
|
*/
|
||||||
INNER( "inner", JoinType.INNER, javax.persistence.criteria.JoinType.INNER ),
|
INNER( "inner", SqlAstJoinType.INNER, javax.persistence.criteria.JoinType.INNER ),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a left outer join.
|
* Represents a left outer join.
|
||||||
*/
|
*/
|
||||||
LEFT( "left outer", JoinType.LEFT, javax.persistence.criteria.JoinType.LEFT ),
|
LEFT( "left outer", SqlAstJoinType.LEFT, javax.persistence.criteria.JoinType.LEFT ),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a right outer join.
|
* Represents a right outer join.
|
||||||
*/
|
*/
|
||||||
RIGHT( "right outer", JoinType.RIGHT, javax.persistence.criteria.JoinType.RIGHT ),
|
RIGHT( "right outer", SqlAstJoinType.RIGHT, javax.persistence.criteria.JoinType.RIGHT ),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a cross join (aka a cartesian product).
|
* Represents a cross join (aka a cartesian product).
|
||||||
*/
|
*/
|
||||||
CROSS( "cross", JoinType.CROSS, null ),
|
CROSS( "cross", SqlAstJoinType.CROSS, null ),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a full join.
|
* Represents a full join.
|
||||||
*/
|
*/
|
||||||
FULL( "full", JoinType.FULL, null );
|
FULL( "full", SqlAstJoinType.FULL, null );
|
||||||
|
|
||||||
private final String text;
|
private final String text;
|
||||||
private final JoinType correspondingSqlJoinType;
|
private final SqlAstJoinType correspondingSqlAstJoinType;
|
||||||
private final javax.persistence.criteria.JoinType correspondingJpaJoinType;
|
private final javax.persistence.criteria.JoinType correspondingJpaJoinType;
|
||||||
|
|
||||||
SqmJoinType(
|
SqmJoinType(
|
||||||
String text,
|
String text,
|
||||||
JoinType correspondingSqlJoinType,
|
SqlAstJoinType correspondingSqlAstJoinType,
|
||||||
javax.persistence.criteria.JoinType correspondingJpaJoinType) {
|
javax.persistence.criteria.JoinType correspondingJpaJoinType) {
|
||||||
this.text = text;
|
this.text = text;
|
||||||
this.correspondingSqlJoinType = correspondingSqlJoinType;
|
this.correspondingSqlAstJoinType = correspondingSqlAstJoinType;
|
||||||
this.correspondingJpaJoinType = correspondingJpaJoinType;
|
this.correspondingJpaJoinType = correspondingJpaJoinType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,8 +68,8 @@ public enum SqmJoinType {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JoinType getCorrespondingSqlJoinType() {
|
public SqlAstJoinType getCorrespondingSqlJoinType() {
|
||||||
return correspondingSqlJoinType;
|
return correspondingSqlAstJoinType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public javax.persistence.criteria.JoinType getCorrespondingJpaJoinType() {
|
public javax.persistence.criteria.JoinType getCorrespondingJpaJoinType() {
|
||||||
|
|
|
@ -9,7 +9,7 @@ package org.hibernate.sql.ast;
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public enum JoinType {
|
public enum SqlAstJoinType {
|
||||||
/**
|
/**
|
||||||
* Represents an inner join.
|
* Represents an inner join.
|
||||||
*/
|
*/
|
||||||
|
@ -37,7 +37,7 @@ public enum JoinType {
|
||||||
|
|
||||||
private final String text;
|
private final String text;
|
||||||
|
|
||||||
JoinType(String text) {
|
SqlAstJoinType(String text) {
|
||||||
this.text = text;
|
this.text = text;
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,7 @@ public class CteTable {
|
||||||
tableValueConstructorReference,
|
tableValueConstructorReference,
|
||||||
Collections.emptyList(),
|
Collections.emptyList(),
|
||||||
null,
|
null,
|
||||||
|
null,
|
||||||
sessionFactory
|
sessionFactory
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,14 @@ public class CteTableGroup implements TableGroup {
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableReference getTableReference(String tableExpression) {
|
||||||
|
if ( cteTableReference.getTableExpression().equals( tableExpression ) ) {
|
||||||
|
return cteTableReference;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableReference resolveTableReference(String tableExpression) {
|
public TableReference resolveTableReference(String tableExpression) {
|
||||||
return cteTableReference;
|
return cteTableReference;
|
||||||
|
|
|
@ -46,6 +46,21 @@ public abstract class AbstractColumnReferenceQualifier implements ColumnReferenc
|
||||||
return tableReference;
|
return tableReference;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableReference getTableReference(String tableExpression) {
|
||||||
|
if ( getPrimaryTableReference().getTableExpression().equals( tableExpression ) ) {
|
||||||
|
return getPrimaryTableReference();
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( TableReferenceJoin tableJoin : getTableReferenceJoins() ) {
|
||||||
|
if ( tableJoin.getJoinedTableReference().getTableExpression().equals( tableExpression ) ) {
|
||||||
|
return tableJoin.getJoinedTableReference();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
protected TableReference resolveTableReferenceInternal(String tableExpression) {
|
protected TableReference resolveTableReferenceInternal(String tableExpression) {
|
||||||
if ( getPrimaryTableReference().getTableExpression().equals( tableExpression ) ) {
|
if ( getPrimaryTableReference().getTableExpression().equals( tableExpression ) ) {
|
||||||
return getPrimaryTableReference();
|
return getPrimaryTableReference();
|
||||||
|
|
|
@ -9,6 +9,7 @@ package org.hibernate.sql.ast.tree.from;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
|
@ -28,6 +29,7 @@ public abstract class AbstractTableGroup extends AbstractColumnReferenceQualifie
|
||||||
|
|
||||||
private Set<TableGroupJoin> tableGroupJoins;
|
private Set<TableGroupJoin> tableGroupJoins;
|
||||||
private boolean isInnerJoinPossible;
|
private boolean isInnerJoinPossible;
|
||||||
|
|
||||||
private final SessionFactoryImplementor sessionFactory;
|
private final SessionFactoryImplementor sessionFactory;
|
||||||
|
|
||||||
@SuppressWarnings("WeakerAccess")
|
@SuppressWarnings("WeakerAccess")
|
||||||
|
|
|
@ -8,13 +8,11 @@ package org.hibernate.sql.ast.tree.from;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import org.hibernate.sql.ast.tree.expression.ColumnReference;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public interface ColumnReferenceQualifier {
|
public interface ColumnReferenceQualifier {
|
||||||
TableReference resolveTableReference(String tableExpression, Supplier<TableReference> creator);
|
TableReference resolveTableReference(String tableExpression, Supplier<TableReference> creator);
|
||||||
TableReference resolveTableReference(String tableExpression);
|
TableReference resolveTableReference(String tableExpression);
|
||||||
|
TableReference getTableReference(String tableExpression);
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,6 +114,11 @@ public class CompositeTableGroup implements VirtualTableGroup {
|
||||||
return underlyingTableGroup.isInnerJoinPossible();
|
return underlyingTableGroup.isInnerJoinPossible();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableReference getTableReference(String tableExpression) {
|
||||||
|
return underlyingTableGroup.getTableReference( tableExpression );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableReference resolveTableReference(
|
public TableReference resolveTableReference(
|
||||||
String tableExpression,
|
String tableExpression,
|
||||||
|
|
|
@ -17,6 +17,9 @@ import org.hibernate.metamodel.mapping.ModelPartContainer;
|
||||||
import org.hibernate.query.NavigablePath;
|
import org.hibernate.query.NavigablePath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Acts as a TableGroup for DML query operations. It is used to simply
|
||||||
|
* wrap the TableReference of the "mutating table"
|
||||||
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class MutatingTableReferenceGroupWrapper implements VirtualTableGroup {
|
public class MutatingTableReferenceGroupWrapper implements VirtualTableGroup {
|
||||||
|
@ -53,6 +56,13 @@ public class MutatingTableReferenceGroupWrapper implements VirtualTableGroup {
|
||||||
return mutatingTableReference;
|
return mutatingTableReference;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableReference getTableReference(String tableExpression) {
|
||||||
|
return mutatingTableReference.getTableExpression().equals( tableExpression )
|
||||||
|
? mutatingTableReference
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableReference resolveTableReference(String tableExpression, Supplier<TableReference> creator) {
|
public TableReference resolveTableReference(String tableExpression, Supplier<TableReference> creator) {
|
||||||
return resolveTableReference( tableExpression );
|
return resolveTableReference( tableExpression );
|
||||||
|
@ -60,9 +70,7 @@ public class MutatingTableReferenceGroupWrapper implements VirtualTableGroup {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableReference resolveTableReference(String tableExpression) {
|
public TableReference resolveTableReference(String tableExpression) {
|
||||||
return mutatingTableReference.getTableExpression().equals( tableExpression )
|
return getTableReference( tableExpression );
|
||||||
? mutatingTableReference
|
|
||||||
: null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -12,7 +12,6 @@ import java.util.function.Supplier;
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
import org.hibernate.metamodel.mapping.ModelPartContainer;
|
import org.hibernate.metamodel.mapping.ModelPartContainer;
|
||||||
import org.hibernate.query.NavigablePath;
|
import org.hibernate.query.NavigablePath;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
||||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||||
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
||||||
|
@ -31,7 +30,7 @@ public interface RootTableGroupProducer extends TableGroupProducer, ModelPartCon
|
||||||
TableGroup createRootTableGroup(
|
TableGroup createRootTableGroup(
|
||||||
NavigablePath navigablePath,
|
NavigablePath navigablePath,
|
||||||
String explicitSourceAlias,
|
String explicitSourceAlias,
|
||||||
JoinType tableReferenceJoinType,
|
boolean canUseInnerJoins,
|
||||||
LockMode lockMode,
|
LockMode lockMode,
|
||||||
SqlAliasBaseGenerator aliasBaseGenerator,
|
SqlAliasBaseGenerator aliasBaseGenerator,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
|
|
@ -6,7 +6,10 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.sql.ast.tree.from;
|
package org.hibernate.sql.ast.tree.from;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
|
@ -19,7 +22,9 @@ import org.hibernate.sql.ast.spi.SqlAliasBase;
|
||||||
*/
|
*/
|
||||||
public class StandardTableGroup extends AbstractTableGroup {
|
public class StandardTableGroup extends AbstractTableGroup {
|
||||||
private final TableReference primaryTableReference;
|
private final TableReference primaryTableReference;
|
||||||
private final List<TableReferenceJoin> tableJoins;
|
private final BiFunction<String,TableGroup,TableReferenceJoin> tableReferenceJoinCreator;
|
||||||
|
|
||||||
|
private List<TableReferenceJoin> tableJoins;
|
||||||
|
|
||||||
public StandardTableGroup(
|
public StandardTableGroup(
|
||||||
NavigablePath navigablePath,
|
NavigablePath navigablePath,
|
||||||
|
@ -28,10 +33,12 @@ public class StandardTableGroup extends AbstractTableGroup {
|
||||||
TableReference primaryTableReference,
|
TableReference primaryTableReference,
|
||||||
List<TableReferenceJoin> tableJoins,
|
List<TableReferenceJoin> tableJoins,
|
||||||
SqlAliasBase sqlAliasBase,
|
SqlAliasBase sqlAliasBase,
|
||||||
|
BiFunction<String,TableGroup,TableReferenceJoin> tableReferenceJoinCreator,
|
||||||
SessionFactoryImplementor sessionFactory) {
|
SessionFactoryImplementor sessionFactory) {
|
||||||
super( navigablePath, tableGroupProducer, lockMode, sqlAliasBase, sessionFactory );
|
super( navigablePath, tableGroupProducer, lockMode, sqlAliasBase, sessionFactory );
|
||||||
this.primaryTableReference = primaryTableReference;
|
this.primaryTableReference = primaryTableReference;
|
||||||
this.tableJoins = tableJoins;
|
this.tableJoins = tableJoins;
|
||||||
|
this.tableReferenceJoinCreator = tableReferenceJoinCreator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -50,18 +57,23 @@ public class StandardTableGroup extends AbstractTableGroup {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TableReferenceJoin> getTableReferenceJoins() {
|
public List<TableReferenceJoin> getTableReferenceJoins() {
|
||||||
return tableJoins;
|
return tableJoins == null ? Collections.emptyList() : tableJoins;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableReference resolveTableReferenceInternal(String tableExpression) {
|
public TableReference resolveTableReferenceInternal(String tableExpression) {
|
||||||
TableReference tableReference = super.resolveTableReferenceInternal( tableExpression );
|
final TableReference tableReference = super.resolveTableReferenceInternal( tableExpression );
|
||||||
if ( tableReference != null ) {
|
if ( tableReference != null ) {
|
||||||
return tableReference;
|
return tableReference;
|
||||||
}
|
}
|
||||||
for ( TableReferenceJoin tableJoin : tableJoins ) {
|
|
||||||
if ( tableJoin.getJoinedTableReference().getTableExpression().equals( tableExpression ) ) {
|
if ( tableJoins != null ) {
|
||||||
return tableJoin.getJoinedTableReference();
|
for ( int i = 0; i < tableJoins.size(); i++ ) {
|
||||||
|
final TableReferenceJoin join = tableJoins.get( i );
|
||||||
|
assert join != null;
|
||||||
|
if ( join.getJoinedTableReference().getTableExpression().equals( tableExpression ) ) {
|
||||||
|
return join.getJoinedTableReference();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,6 +83,21 @@ public class StandardTableGroup extends AbstractTableGroup {
|
||||||
return primaryTableReference;
|
return primaryTableReference;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return potentiallyCreateTableReference( tableExpression );
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("WeakerAccess")
|
||||||
|
protected TableReference potentiallyCreateTableReference(String tableExpression) {
|
||||||
|
final TableReferenceJoin join = tableReferenceJoinCreator.apply( tableExpression, this );
|
||||||
|
if ( join != null ) {
|
||||||
|
if ( tableJoins == null ) {
|
||||||
|
tableJoins = new ArrayList<>();
|
||||||
|
}
|
||||||
|
tableJoins.add( join );
|
||||||
|
return join.getJoinedTableReference();
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,14 +7,12 @@
|
||||||
package org.hibernate.sql.ast.tree.from;
|
package org.hibernate.sql.ast.tree.from;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.query.NavigablePath;
|
import org.hibernate.query.NavigablePath;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,22 +24,14 @@ public class TableGroupBuilder implements TableReferenceCollector {
|
||||||
TableGroupProducer producer,
|
TableGroupProducer producer,
|
||||||
LockMode lockMode,
|
LockMode lockMode,
|
||||||
SqlAliasBase sqlAliasBase,
|
SqlAliasBase sqlAliasBase,
|
||||||
|
BiFunction<String,TableGroup,TableReferenceJoin> tableReferenceJoinCreator,
|
||||||
SessionFactoryImplementor sessionFactory) {
|
SessionFactoryImplementor sessionFactory) {
|
||||||
return new TableGroupBuilder( path, producer, lockMode, sqlAliasBase, sessionFactory );
|
return new TableGroupBuilder( path, producer, lockMode, sqlAliasBase, tableReferenceJoinCreator, sessionFactory );
|
||||||
}
|
|
||||||
|
|
||||||
public static TableGroupBuilder builder(
|
|
||||||
NavigablePath path,
|
|
||||||
TableGroupProducer producer,
|
|
||||||
LockMode lockMode,
|
|
||||||
SqlAliasBase sqlAliasBase,
|
|
||||||
BiFunction<TableReference, TableReference,TableReferenceJoin> primaryJoinProducer,
|
|
||||||
SessionFactoryImplementor sessionFactory) {
|
|
||||||
return new TableGroupBuilder( path, producer, lockMode, sqlAliasBase, primaryJoinProducer, sessionFactory );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final NavigablePath path;
|
private final NavigablePath path;
|
||||||
private final TableGroupProducer producer;
|
private final TableGroupProducer producer;
|
||||||
|
private final BiFunction<String, TableGroup, TableReferenceJoin> tableReferenceJoinCreator;
|
||||||
private final SessionFactoryImplementor sessionFactory;
|
private final SessionFactoryImplementor sessionFactory;
|
||||||
|
|
||||||
private final SqlAliasBase sqlAliasBase;
|
private final SqlAliasBase sqlAliasBase;
|
||||||
|
@ -59,25 +49,28 @@ public class TableGroupBuilder implements TableReferenceCollector {
|
||||||
TableGroupProducer producer,
|
TableGroupProducer producer,
|
||||||
LockMode lockMode,
|
LockMode lockMode,
|
||||||
SqlAliasBase sqlAliasBase,
|
SqlAliasBase sqlAliasBase,
|
||||||
SessionFactoryImplementor sessionFactory) {
|
BiFunction<String, TableGroup, TableReferenceJoin> tableReferenceJoinCreator,
|
||||||
this( path, producer, lockMode, sqlAliasBase, null, sessionFactory );
|
|
||||||
}
|
|
||||||
|
|
||||||
private TableGroupBuilder(
|
|
||||||
NavigablePath path,
|
|
||||||
TableGroupProducer producer,
|
|
||||||
LockMode lockMode,
|
|
||||||
SqlAliasBase sqlAliasBase,
|
|
||||||
BiFunction<TableReference, TableReference,TableReferenceJoin> primaryJoinProducer,
|
|
||||||
SessionFactoryImplementor sessionFactory) {
|
SessionFactoryImplementor sessionFactory) {
|
||||||
this.path = path;
|
this.path = path;
|
||||||
this.producer = producer;
|
this.producer = producer;
|
||||||
this.lockMode = lockMode;
|
this.lockMode = lockMode;
|
||||||
this.sqlAliasBase = sqlAliasBase;
|
this.sqlAliasBase = sqlAliasBase;
|
||||||
this.primaryJoinProducer = primaryJoinProducer;
|
this.tableReferenceJoinCreator = tableReferenceJoinCreator;
|
||||||
this.sessionFactory = sessionFactory;
|
this.sessionFactory = sessionFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NavigablePath getPath() {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SessionFactoryImplementor getSessionFactory() {
|
||||||
|
return sessionFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SqlAliasBase getSqlAliasBase() {
|
||||||
|
return sqlAliasBase;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void applyPrimaryJoinProducer(BiFunction<TableReference, TableReference, TableReferenceJoin> primaryJoinProducer) {
|
public void applyPrimaryJoinProducer(BiFunction<TableReference, TableReference, TableReferenceJoin> primaryJoinProducer) {
|
||||||
this.primaryJoinProducer = primaryJoinProducer;
|
this.primaryJoinProducer = primaryJoinProducer;
|
||||||
|
@ -93,8 +86,9 @@ public class TableGroupBuilder implements TableReferenceCollector {
|
||||||
producer,
|
producer,
|
||||||
lockMode,
|
lockMode,
|
||||||
primaryTableReference,
|
primaryTableReference,
|
||||||
tableJoins == null ? Collections.emptyList() : tableJoins,
|
tableJoins,
|
||||||
sqlAliasBase,
|
sqlAliasBase,
|
||||||
|
tableReferenceJoinCreator,
|
||||||
sessionFactory
|
sessionFactory
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -115,7 +109,7 @@ public class TableGroupBuilder implements TableReferenceCollector {
|
||||||
@Override
|
@Override
|
||||||
public void applySecondaryTableReferences(
|
public void applySecondaryTableReferences(
|
||||||
TableReference tableReference,
|
TableReference tableReference,
|
||||||
JoinType tableReferenceJoinType,
|
SqlAstJoinType tableReferenceSqlAstJoinType,
|
||||||
TableReferenceJoinPredicateProducer predicateProducer) {
|
TableReferenceJoinPredicateProducer predicateProducer) {
|
||||||
if ( primaryTableReference == null ) {
|
if ( primaryTableReference == null ) {
|
||||||
primaryTableReference = tableReference;
|
primaryTableReference = tableReference;
|
||||||
|
@ -124,12 +118,12 @@ public class TableGroupBuilder implements TableReferenceCollector {
|
||||||
else {
|
else {
|
||||||
addTableReferenceJoin(
|
addTableReferenceJoin(
|
||||||
new TableReferenceJoin(
|
new TableReferenceJoin(
|
||||||
tableReferenceJoinType,
|
tableReferenceSqlAstJoinType,
|
||||||
tableReference,
|
tableReference,
|
||||||
predicateProducer.producePredicate(
|
predicateProducer.producePredicate(
|
||||||
secondaryTableLhs,
|
secondaryTableLhs,
|
||||||
tableReference,
|
tableReference,
|
||||||
tableReferenceJoinType
|
tableReferenceSqlAstJoinType
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
package org.hibernate.sql.ast.tree.from;
|
package org.hibernate.sql.ast.tree.from;
|
||||||
|
|
||||||
import org.hibernate.query.NavigablePath;
|
import org.hibernate.query.NavigablePath;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||||
import org.hibernate.sql.ast.spi.SqlAstTreeHelper;
|
import org.hibernate.sql.ast.spi.SqlAstTreeHelper;
|
||||||
import org.hibernate.sql.ast.SqlAstWalker;
|
import org.hibernate.sql.ast.SqlAstWalker;
|
||||||
import org.hibernate.sql.ast.tree.SqlAstNode;
|
import org.hibernate.sql.ast.tree.SqlAstNode;
|
||||||
|
@ -21,31 +21,31 @@ import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||||
*/
|
*/
|
||||||
public class TableGroupJoin implements SqlAstNode, DomainResultProducer {
|
public class TableGroupJoin implements SqlAstNode, DomainResultProducer {
|
||||||
private final NavigablePath navigablePath;
|
private final NavigablePath navigablePath;
|
||||||
private final JoinType joinType;
|
private final SqlAstJoinType sqlAstJoinType;
|
||||||
private final TableGroup joinedGroup;
|
private final TableGroup joinedGroup;
|
||||||
|
|
||||||
private Predicate predicate;
|
private Predicate predicate;
|
||||||
|
|
||||||
public TableGroupJoin(
|
public TableGroupJoin(
|
||||||
NavigablePath navigablePath,
|
NavigablePath navigablePath,
|
||||||
JoinType joinType,
|
SqlAstJoinType sqlAstJoinType,
|
||||||
TableGroup joinedGroup,
|
TableGroup joinedGroup,
|
||||||
Predicate predicate) {
|
Predicate predicate) {
|
||||||
this.navigablePath = navigablePath;
|
this.navigablePath = navigablePath;
|
||||||
this.joinType = joinType;
|
this.sqlAstJoinType = sqlAstJoinType;
|
||||||
this.joinedGroup = joinedGroup;
|
this.joinedGroup = joinedGroup;
|
||||||
this.predicate = predicate;
|
this.predicate = predicate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TableGroupJoin(
|
public TableGroupJoin(
|
||||||
NavigablePath navigablePath,
|
NavigablePath navigablePath,
|
||||||
JoinType joinType,
|
SqlAstJoinType sqlAstJoinType,
|
||||||
TableGroup joinedGroup) {
|
TableGroup joinedGroup) {
|
||||||
this( navigablePath, joinType, joinedGroup, null );
|
this( navigablePath, sqlAstJoinType, joinedGroup, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
public JoinType getJoinType() {
|
public SqlAstJoinType getJoinType() {
|
||||||
return joinType;
|
return sqlAstJoinType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TableGroup getJoinedGroup() {
|
public TableGroup getJoinedGroup() {
|
||||||
|
|
|
@ -8,7 +8,7 @@ package org.hibernate.sql.ast.tree.from;
|
||||||
|
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
import org.hibernate.query.NavigablePath;
|
import org.hibernate.query.NavigablePath;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
||||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||||
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
||||||
|
@ -24,7 +24,7 @@ public interface TableGroupJoinProducer extends TableGroupProducer {
|
||||||
NavigablePath navigablePath,
|
NavigablePath navigablePath,
|
||||||
TableGroup lhs,
|
TableGroup lhs,
|
||||||
String explicitSourceAlias,
|
String explicitSourceAlias,
|
||||||
JoinType joinType,
|
SqlAstJoinType sqlAstJoinType,
|
||||||
LockMode lockMode,
|
LockMode lockMode,
|
||||||
SqlAliasBaseGenerator aliasBaseGenerator,
|
SqlAliasBaseGenerator aliasBaseGenerator,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
|
|
@ -71,6 +71,14 @@ public class TableReference implements SqlAstNode, ColumnReferenceQualifier {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableReference getTableReference(String tableExpression) {
|
||||||
|
if ( this.tableExpression.equals( tableExpression ) ) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getTableExpression() + "(" + getIdentificationVariable() + ')';
|
return getTableExpression() + "(" + getIdentificationVariable() + ')';
|
||||||
|
|
|
@ -8,7 +8,7 @@ package org.hibernate.sql.ast.tree.from;
|
||||||
|
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
import org.hibernate.sql.ast.JoinType;
|
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used in constructing {@link TableGroup} references to collect the individual table
|
* Used in constructing {@link TableGroup} references to collect the individual table
|
||||||
|
@ -25,14 +25,14 @@ public interface TableReferenceCollector {
|
||||||
* Collect a table reference as part of the TableGroup.
|
* Collect a table reference as part of the TableGroup.
|
||||||
*
|
*
|
||||||
* @param tableReference The TableReference.
|
* @param tableReference The TableReference.
|
||||||
* @param joinType The type of join indicated by the mapping of the table, if it is to be joined
|
* @param sqlAstJoinType The type of join indicated by the mapping of the table, if it is to be joined
|
||||||
* @param predicateProducer Function for creating the join predicate, if it is to be joined. The first
|
* @param predicateProducer Function for creating the join predicate, if it is to be joined. The first
|
||||||
* argument passed to the function is the LHS reference. The second is the same as `tableReference`.
|
* argument passed to the function is the LHS reference. The second is the same as `tableReference`.
|
||||||
* The result is a SQL AST Predicate to use as the join-predicate
|
* The result is a SQL AST Predicate to use as the join-predicate
|
||||||
*/
|
*/
|
||||||
void applySecondaryTableReferences(
|
void applySecondaryTableReferences(
|
||||||
TableReference tableReference,
|
TableReference tableReference,
|
||||||
JoinType joinType,
|
SqlAstJoinType sqlAstJoinType,
|
||||||
TableReferenceJoinPredicateProducer predicateProducer);
|
TableReferenceJoinPredicateProducer predicateProducer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
package org.hibernate.sql.ast.tree.from;
|
package org.hibernate.sql.ast.tree.from;
|
||||||
|
|
||||||
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
||||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||||
|
|
||||||
|
@ -20,8 +20,25 @@ public interface TableReferenceContributor {
|
||||||
*/
|
*/
|
||||||
void applyTableReferences(
|
void applyTableReferences(
|
||||||
SqlAliasBase sqlAliasBase,
|
SqlAliasBase sqlAliasBase,
|
||||||
JoinType baseJoinType,
|
SqlAstJoinType baseSqlAstJoinType,
|
||||||
TableReferenceCollector collector,
|
TableReferenceCollector collector,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
SqlAstCreationContext creationContext);
|
SqlAstCreationContext creationContext);
|
||||||
|
|
||||||
|
default TableReference createPrimaryTableReference(
|
||||||
|
SqlAliasBase sqlAliasBase,
|
||||||
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
SqlAstCreationContext creationContext) {
|
||||||
|
throw new UnsupportedOperationException( "Contributor [" + getClass().getName() + "] does not support primary TableReference creation" );
|
||||||
|
}
|
||||||
|
|
||||||
|
default TableReferenceJoin createTableReferenceJoin(
|
||||||
|
String joinTableExpression,
|
||||||
|
SqlAliasBase sqlAliasBase,
|
||||||
|
TableReference lhs,
|
||||||
|
boolean canUseInnerJoin,
|
||||||
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
|
SqlAstCreationContext creationContext) {
|
||||||
|
throw new UnsupportedOperationException( "Contributor [" + getClass().getName() + "] does not support TableReference join creation" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.sql.ast.tree.from;
|
package org.hibernate.sql.ast.tree.from;
|
||||||
|
|
||||||
import org.hibernate.sql.ast.JoinType;
|
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||||
import org.hibernate.sql.ast.SqlAstWalker;
|
import org.hibernate.sql.ast.SqlAstWalker;
|
||||||
import org.hibernate.sql.ast.tree.SqlAstNode;
|
import org.hibernate.sql.ast.tree.SqlAstNode;
|
||||||
import org.hibernate.sql.ast.tree.predicate.Predicate;
|
import org.hibernate.sql.ast.tree.predicate.Predicate;
|
||||||
|
@ -17,12 +17,12 @@ import org.hibernate.sql.ast.tree.predicate.Predicate;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class TableReferenceJoin implements SqlAstNode {
|
public class TableReferenceJoin implements SqlAstNode {
|
||||||
private final JoinType joinType;
|
private final SqlAstJoinType sqlAstJoinType;
|
||||||
private final TableReference joinedTableBinding;
|
private final TableReference joinedTableBinding;
|
||||||
private final Predicate predicate;
|
private final Predicate predicate;
|
||||||
|
|
||||||
public TableReferenceJoin(JoinType joinType, TableReference joinedTableBinding, Predicate predicate) {
|
public TableReferenceJoin(SqlAstJoinType sqlAstJoinType, TableReference joinedTableBinding, Predicate predicate) {
|
||||||
this.joinType = joinType == null ? JoinType.LEFT : joinType;
|
this.sqlAstJoinType = sqlAstJoinType == null ? SqlAstJoinType.LEFT : sqlAstJoinType;
|
||||||
this.joinedTableBinding = joinedTableBinding;
|
this.joinedTableBinding = joinedTableBinding;
|
||||||
this.predicate = predicate;
|
this.predicate = predicate;
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@ public class TableReferenceJoin implements SqlAstNode {
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public JoinType getJoinType() {
|
public SqlAstJoinType getJoinType() {
|
||||||
return joinType;
|
return sqlAstJoinType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TableReference getJoinedTableReference() {
|
public TableReference getJoinedTableReference() {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.sql.ast.tree.from;
|
package org.hibernate.sql.ast.tree.from;
|
||||||
|
|
||||||
import org.hibernate.sql.ast.JoinType;
|
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||||
import org.hibernate.sql.ast.tree.predicate.Predicate;
|
import org.hibernate.sql.ast.tree.predicate.Predicate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,5 +20,5 @@ import org.hibernate.sql.ast.tree.predicate.Predicate;
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public
|
public
|
||||||
interface TableReferenceJoinPredicateProducer {
|
interface TableReferenceJoinPredicateProducer {
|
||||||
Predicate producePredicate(TableReference lhs, TableReference rhs, JoinType joinType);
|
Predicate producePredicate(TableReference lhs, TableReference rhs, SqlAstJoinType sqlAstJoinType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ import java.util.function.Consumer;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
import org.hibernate.NotYetImplementedFor6Exception;
|
|
||||||
import org.hibernate.metamodel.mapping.ModelPartContainer;
|
import org.hibernate.metamodel.mapping.ModelPartContainer;
|
||||||
import org.hibernate.persister.entity.UnionSubclassEntityPersister;
|
import org.hibernate.persister.entity.UnionSubclassEntityPersister;
|
||||||
import org.hibernate.query.NavigablePath;
|
import org.hibernate.query.NavigablePath;
|
||||||
|
@ -98,13 +97,20 @@ public class UnionTableGroup implements VirtualTableGroup {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableReference resolveTableReference(
|
public TableReference getTableReference(String tableExpression) {
|
||||||
String tableExpression, Supplier<TableReference> creator) {
|
assert tableReference.getTableExpression().equals( tableExpression );
|
||||||
|
return tableReference;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableReference resolveTableReference(String tableExpression, Supplier<TableReference> creator) {
|
||||||
|
assert tableReference.getTableExpression().equals( tableExpression );
|
||||||
return tableReference;
|
return tableReference;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableReference resolveTableReference(String tableExpression) {
|
public TableReference resolveTableReference(String tableExpression) {
|
||||||
|
// assert tableReference.getTableExpression().equals( tableExpression );
|
||||||
return tableReference;
|
return tableReference;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,6 +102,11 @@ public class EntityCollectionPartTableGroup implements TableGroup {
|
||||||
return collectionTableGroup.isInnerJoinPossible();
|
return collectionTableGroup.isInnerJoinPossible();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableReference getTableReference(String tableExpression) {
|
||||||
|
return collectionTableGroup.getTableReference( tableExpression );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableReference resolveTableReference(String tableExpression, Supplier<TableReference> creator) {
|
public TableReference resolveTableReference(String tableExpression, Supplier<TableReference> creator) {
|
||||||
return collectionTableGroup.resolveTableReference( tableExpression, creator );
|
return collectionTableGroup.resolveTableReference( tableExpression, creator );
|
||||||
|
|
|
@ -14,7 +14,7 @@ import org.hibernate.sql.results.graph.embeddable.EmbeddableValuedFetchable;
|
||||||
import org.hibernate.metamodel.mapping.EmbeddableMappingType;
|
import org.hibernate.metamodel.mapping.EmbeddableMappingType;
|
||||||
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
|
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
|
||||||
import org.hibernate.query.NavigablePath;
|
import org.hibernate.query.NavigablePath;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||||
import org.hibernate.sql.ast.tree.from.TableGroupJoin;
|
import org.hibernate.sql.ast.tree.from.TableGroupJoin;
|
||||||
import org.hibernate.sql.results.graph.AbstractFetchParent;
|
import org.hibernate.sql.results.graph.AbstractFetchParent;
|
||||||
import org.hibernate.sql.results.graph.AssemblerCreationState;
|
import org.hibernate.sql.results.graph.AssemblerCreationState;
|
||||||
|
@ -57,7 +57,7 @@ public class EmbeddableFetchImpl extends AbstractFetchParent implements Embeddab
|
||||||
.getFromClauseAccess()
|
.getFromClauseAccess()
|
||||||
.findTableGroup( fetchParent.getNavigablePath() ),
|
.findTableGroup( fetchParent.getNavigablePath() ),
|
||||||
null,
|
null,
|
||||||
nullable ? JoinType.LEFT : JoinType.INNER,
|
nullable ? SqlAstJoinType.LEFT : SqlAstJoinType.INNER,
|
||||||
LockMode.NONE,
|
LockMode.NONE,
|
||||||
stem -> creationState.getSqlAliasBaseManager().createSqlAliasBase( stem ),
|
stem -> creationState.getSqlAliasBaseManager().createSqlAliasBase( stem ),
|
||||||
creationState.getSqlAstCreationState().getSqlExpressionResolver(),
|
creationState.getSqlAstCreationState().getSqlExpressionResolver(),
|
||||||
|
|
|
@ -12,7 +12,7 @@ import org.hibernate.LockMode;
|
||||||
import org.hibernate.metamodel.mapping.EmbeddableMappingType;
|
import org.hibernate.metamodel.mapping.EmbeddableMappingType;
|
||||||
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
|
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
|
||||||
import org.hibernate.query.NavigablePath;
|
import org.hibernate.query.NavigablePath;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||||
import org.hibernate.sql.ast.spi.FromClauseAccess;
|
import org.hibernate.sql.ast.spi.FromClauseAccess;
|
||||||
import org.hibernate.sql.ast.tree.from.TableGroupJoin;
|
import org.hibernate.sql.ast.tree.from.TableGroupJoin;
|
||||||
import org.hibernate.sql.results.graph.AbstractFetchParent;
|
import org.hibernate.sql.results.graph.AbstractFetchParent;
|
||||||
|
@ -48,7 +48,7 @@ public class EmbeddableResultImpl<T> extends AbstractFetchParent implements Embe
|
||||||
navigablePath,
|
navigablePath,
|
||||||
fromClauseAccess.findTableGroup( navigablePath.getParent() ),
|
fromClauseAccess.findTableGroup( navigablePath.getParent() ),
|
||||||
resultVariable,
|
resultVariable,
|
||||||
JoinType.INNER,
|
SqlAstJoinType.INNER,
|
||||||
LockMode.NONE,
|
LockMode.NONE,
|
||||||
creationState.getSqlAstCreationState().getSqlAliasBaseGenerator(),
|
creationState.getSqlAstCreationState().getSqlAliasBaseGenerator(),
|
||||||
creationState.getSqlAstCreationState().getSqlExpressionResolver(),
|
creationState.getSqlAstCreationState().getSqlExpressionResolver(),
|
||||||
|
|
|
@ -60,7 +60,7 @@ import org.hibernate.persister.spi.PersisterCreationContext;
|
||||||
import org.hibernate.persister.walking.spi.AttributeDefinition;
|
import org.hibernate.persister.walking.spi.AttributeDefinition;
|
||||||
import org.hibernate.persister.walking.spi.EntityIdentifierDefinition;
|
import org.hibernate.persister.walking.spi.EntityIdentifierDefinition;
|
||||||
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
||||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||||
import org.hibernate.sql.ast.tree.from.TableReferenceCollector;
|
import org.hibernate.sql.ast.tree.from.TableReferenceCollector;
|
||||||
|
@ -727,7 +727,7 @@ public class PersisterClassProviderTest {
|
||||||
@Override
|
@Override
|
||||||
public void applyTableReferences(
|
public void applyTableReferences(
|
||||||
SqlAliasBase sqlAliasBase,
|
SqlAliasBase sqlAliasBase,
|
||||||
JoinType baseJoinType,
|
SqlAstJoinType baseSqlAstJoinType,
|
||||||
TableReferenceCollector collector,
|
TableReferenceCollector collector,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
SqlAstCreationContext creationContext) {
|
SqlAstCreationContext creationContext) {
|
||||||
|
|
|
@ -60,7 +60,7 @@ import org.hibernate.persister.walking.spi.CollectionElementDefinition;
|
||||||
import org.hibernate.persister.walking.spi.CollectionIndexDefinition;
|
import org.hibernate.persister.walking.spi.CollectionIndexDefinition;
|
||||||
import org.hibernate.persister.walking.spi.EntityIdentifierDefinition;
|
import org.hibernate.persister.walking.spi.EntityIdentifierDefinition;
|
||||||
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
||||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||||
import org.hibernate.sql.ast.tree.from.TableReferenceCollector;
|
import org.hibernate.sql.ast.tree.from.TableReferenceCollector;
|
||||||
|
@ -713,7 +713,7 @@ public class GoofyPersisterClassProvider implements PersisterClassResolver {
|
||||||
@Override
|
@Override
|
||||||
public void applyTableReferences(
|
public void applyTableReferences(
|
||||||
SqlAliasBase sqlAliasBase,
|
SqlAliasBase sqlAliasBase,
|
||||||
JoinType baseJoinType,
|
SqlAstJoinType baseSqlAstJoinType,
|
||||||
TableReferenceCollector collector,
|
TableReferenceCollector collector,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
SqlAstCreationContext creationContext) {
|
SqlAstCreationContext creationContext) {
|
||||||
|
|
|
@ -60,7 +60,7 @@ import org.hibernate.persister.entity.MultiLoadOptions;
|
||||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
import org.hibernate.persister.spi.PersisterCreationContext;
|
||||||
import org.hibernate.persister.walking.spi.AttributeDefinition;
|
import org.hibernate.persister.walking.spi.AttributeDefinition;
|
||||||
import org.hibernate.persister.walking.spi.EntityIdentifierDefinition;
|
import org.hibernate.persister.walking.spi.EntityIdentifierDefinition;
|
||||||
import org.hibernate.sql.ast.JoinType;
|
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||||
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
||||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||||
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
||||||
|
@ -826,7 +826,7 @@ public class CustomPersister implements EntityPersister {
|
||||||
@Override
|
@Override
|
||||||
public void applyTableReferences(
|
public void applyTableReferences(
|
||||||
SqlAliasBase sqlAliasBase,
|
SqlAliasBase sqlAliasBase,
|
||||||
JoinType baseJoinType,
|
SqlAstJoinType baseSqlAstJoinType,
|
||||||
TableReferenceCollector collector,
|
TableReferenceCollector collector,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
SqlAstCreationContext creationContext) {
|
SqlAstCreationContext creationContext) {
|
||||||
|
|
Loading…
Reference in New Issue