Package org.hibernate.sql.ast.tree.from
Class DelegatingTableGroup
- java.lang.Object
-
- org.hibernate.sql.ast.tree.from.DelegatingTableGroup
-
- All Implemented Interfaces:
DomainResultProducer
,SqmPathInterpretation
,SqlSelectionProducer
,Expression
,ColumnReferenceQualifier
,TableGroup
,SqlAstNode
- Direct Known Subclasses:
LazyTableGroup
,MappedByTableGroup
public abstract class DelegatingTableGroup extends Object implements TableGroup
-
-
Constructor Summary
Constructors Constructor Description DelegatingTableGroup()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
accept(SqlAstWalker sqlTreeWalker)
void
addNestedTableGroupJoin(TableGroupJoin join)
A nested table group join is a join against a table group, that is ensured to be joined against the primary table reference and table reference joins in isolation, prior to doing other table group joins e.g.void
addTableGroupJoin(TableGroupJoin join)
void
applyAffectedTableNames(Consumer<String> nameCollector)
void
applySqlSelections(DomainResultCreationState creationState)
Used when this producer is a selection in a sub-query.boolean
canUseInnerJoins()
DomainResult
createDomainResult(String resultVariable, DomainResultCreationState creationState)
Produce the domain querySqlSelection
createSqlSelection(int jdbcPosition, int valuesArrayPosition, JavaType javaType, boolean virtual, TypeConfiguration typeConfiguration)
Create a SqlSelection for the given JDBC ResultSet positionSqlSelection
createSqlSelection(int jdbcPosition, int valuesArrayPosition, JavaType javaType, TypeConfiguration typeConfiguration)
Create a SqlSelection for the given JDBC ResultSet positionColumnReference
getColumnReference()
ModelPart
getExpressionType()
The type for this expressionString
getGroupAlias()
If we want to use CTE for TableGroup rendering we will need to know the alias we can use for the groupModelPartContainer
getModelPart()
NavigablePath
getNavigablePath()
List<TableGroupJoin>
getNestedTableGroupJoins()
TableReference
getPrimaryTableReference()
String
getSourceAlias()
Expression
getSqlExpression()
protected abstract TableGroup
getTableGroup()
List<TableGroupJoin>
getTableGroupJoins()
TableReference
getTableReference(NavigablePath navigablePath, String tableExpression, boolean resolve)
Returns the table reference for the table expression, or null if not found.TableReference
getTableReference(NavigablePath navigablePath, ValuedModelPart modelPart, String tableExpression, boolean resolve)
List<TableReferenceJoin>
getTableReferenceJoins()
boolean
isFetched()
boolean
isInitialized()
If this is a lazy table group, it may report that it is not initialized, which would also mean that a join referring to this table group should not be rendered.boolean
isLateral()
boolean
isRealTableGroup()
void
prependTableGroupJoin(NavigablePath navigablePath, TableGroupJoin join)
Adds the given table group join before a join as found via the given navigable path.void
visitNestedTableGroupJoins(Consumer<TableGroupJoin> consumer)
void
visitTableGroupJoins(Consumer<TableGroupJoin> consumer)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.sql.ast.tree.from.ColumnReferenceQualifier
getTableReference, getTableReference, resolveTableReference, resolveTableReference, resolveTableReference
-
Methods inherited from interface org.hibernate.sql.ast.tree.expression.Expression
createDomainResultSqlSelection, createDomainResultSqlSelection
-
Methods inherited from interface org.hibernate.sql.ast.tree.from.TableGroup
findCompatibleJoinedGroup, findTableGroupJoin, hasRealJoins, isVirtual
-
-
-
-
Method Detail
-
getTableGroup
protected abstract TableGroup getTableGroup()
-
getExpressionType
public ModelPart getExpressionType()
Description copied from interface:Expression
The type for this expression- Specified by:
getExpressionType
in interfaceExpression
- Specified by:
getExpressionType
in interfaceSqmPathInterpretation
-
getSqlExpression
public Expression getSqlExpression()
- Specified by:
getSqlExpression
in interfaceSqmPathInterpretation
-
getColumnReference
public ColumnReference getColumnReference()
- Specified by:
getColumnReference
in interfaceExpression
-
createSqlSelection
public SqlSelection createSqlSelection(int jdbcPosition, int valuesArrayPosition, JavaType javaType, TypeConfiguration typeConfiguration)
Description copied from interface:SqlSelectionProducer
Create a SqlSelection for the given JDBC ResultSet position- Specified by:
createSqlSelection
in interfaceExpression
- Specified by:
createSqlSelection
in interfaceSqlSelectionProducer
- Parameters:
jdbcPosition
- The index position used to read values from JDBCvaluesArrayPosition
- The position in our "current JDBC values array"javaType
- The descriptor for the Java type to read the value astypeConfiguration
- The associated TypeConfiguration
-
createSqlSelection
public SqlSelection createSqlSelection(int jdbcPosition, int valuesArrayPosition, JavaType javaType, boolean virtual, TypeConfiguration typeConfiguration)
Description copied from interface:SqlSelectionProducer
Create a SqlSelection for the given JDBC ResultSet position- Specified by:
createSqlSelection
in interfaceExpression
- Specified by:
createSqlSelection
in interfaceSqlSelectionProducer
- Parameters:
jdbcPosition
- The index position used to read values from JDBCvaluesArrayPosition
- The position in our "current JDBC values array"javaType
- The descriptor for the Java type to read the value asvirtual
- Whether the select is virtual or real. SeeSqlSelection.isVirtual()
typeConfiguration
- The associated TypeConfiguration
-
getTableReference
public TableReference getTableReference(NavigablePath navigablePath, String tableExpression, boolean resolve)
Description copied from interface:ColumnReferenceQualifier
Returns the table reference for the table expression, or null if not found.- Specified by:
getTableReference
in interfaceColumnReferenceQualifier
- Parameters:
navigablePath
- The path for which to look up the table reference, may be nulltableExpression
- The table expression for which to look up the table referenceresolve
- Whether to potentially create table reference joins for this table group
-
getTableReference
public TableReference getTableReference(NavigablePath navigablePath, ValuedModelPart modelPart, String tableExpression, boolean resolve)
- Specified by:
getTableReference
in interfaceColumnReferenceQualifier
-
getNavigablePath
public NavigablePath getNavigablePath()
- Specified by:
getNavigablePath
in interfaceSqmPathInterpretation
- Specified by:
getNavigablePath
in interfaceTableGroup
-
getGroupAlias
public String getGroupAlias()
Description copied from interface:TableGroup
If we want to use CTE for TableGroup rendering we will need to know the alias we can use for the group- Specified by:
getGroupAlias
in interfaceTableGroup
-
getModelPart
public ModelPartContainer getModelPart()
- Specified by:
getModelPart
in interfaceTableGroup
-
getSourceAlias
public String getSourceAlias()
- Specified by:
getSourceAlias
in interfaceTableGroup
-
getTableGroupJoins
public List<TableGroupJoin> getTableGroupJoins()
- Specified by:
getTableGroupJoins
in interfaceTableGroup
-
getNestedTableGroupJoins
public List<TableGroupJoin> getNestedTableGroupJoins()
- Specified by:
getNestedTableGroupJoins
in interfaceTableGroup
-
canUseInnerJoins
public boolean canUseInnerJoins()
- Specified by:
canUseInnerJoins
in interfaceTableGroup
-
isLateral
public boolean isLateral()
- Specified by:
isLateral
in interfaceTableGroup
-
addTableGroupJoin
public void addTableGroupJoin(TableGroupJoin join)
- Specified by:
addTableGroupJoin
in interfaceTableGroup
-
prependTableGroupJoin
public void prependTableGroupJoin(NavigablePath navigablePath, TableGroupJoin join)
Description copied from interface:TableGroup
Adds the given table group join before a join as found via the given navigable path.- Specified by:
prependTableGroupJoin
in interfaceTableGroup
-
addNestedTableGroupJoin
public void addNestedTableGroupJoin(TableGroupJoin join)
Description copied from interface:TableGroup
A nested table group join is a join against a table group, that is ensured to be joined against the primary table reference and table reference joins in isolation, prior to doing other table group joins e.g.select * from entity1 e left join ( collection_table c1 join association a on a.id = c1.target_id ) on c1.entity_id = e.id and c1.key = 1
is modeled asTableGroup( primaryTableReference = TableReference(entity1, e), tableGroupJoins = [ TableGroupJoin( TableGroup( primaryTableReference = TableReference(collection_table, c1), nestedTableGroupJoins = [ TableGroupJoin( TableGroup( primaryTableReference = TableReference(association, a) ) ) ] ) ) ] )
This is necessary to correctly retain the cardinality of an HQL join like e.g.from Entity1 e left join e.collectionAssociation c on key(c) = 1
- Specified by:
addNestedTableGroupJoin
in interfaceTableGroup
-
visitTableGroupJoins
public void visitTableGroupJoins(Consumer<TableGroupJoin> consumer)
- Specified by:
visitTableGroupJoins
in interfaceTableGroup
-
visitNestedTableGroupJoins
public void visitNestedTableGroupJoins(Consumer<TableGroupJoin> consumer)
- Specified by:
visitNestedTableGroupJoins
in interfaceTableGroup
-
applyAffectedTableNames
public void applyAffectedTableNames(Consumer<String> nameCollector)
- Specified by:
applyAffectedTableNames
in interfaceTableGroup
-
getPrimaryTableReference
public TableReference getPrimaryTableReference()
- Specified by:
getPrimaryTableReference
in interfaceTableGroup
-
getTableReferenceJoins
public List<TableReferenceJoin> getTableReferenceJoins()
- Specified by:
getTableReferenceJoins
in interfaceTableGroup
-
createDomainResult
public DomainResult createDomainResult(String resultVariable, DomainResultCreationState creationState)
Description copied from interface:DomainResultProducer
Produce the domain query- Specified by:
createDomainResult
in interfaceDomainResultProducer
- Specified by:
createDomainResult
in interfaceTableGroup
-
applySqlSelections
public void applySqlSelections(DomainResultCreationState creationState)
Description copied from interface:DomainResultProducer
Used when this producer is a selection in a sub-query. The DomainResult is only needed for root query of a SELECT statement. This default impl assumes this producer is a true (Sql)Expression- Specified by:
applySqlSelections
in interfaceDomainResultProducer
- Specified by:
applySqlSelections
in interfaceTableGroup
-
accept
public void accept(SqlAstWalker sqlTreeWalker)
- Specified by:
accept
in interfaceSqlAstNode
- Specified by:
accept
in interfaceTableGroup
-
isRealTableGroup
public boolean isRealTableGroup()
- Specified by:
isRealTableGroup
in interfaceTableGroup
-
isFetched
public boolean isFetched()
- Specified by:
isFetched
in interfaceTableGroup
-
isInitialized
public boolean isInitialized()
Description copied from interface:TableGroup
If this is a lazy table group, it may report that it is not initialized, which would also mean that a join referring to this table group should not be rendered.- Specified by:
isInitialized
in interfaceTableGroup
-
-