Top Description Inners Fields Constructors Methods
org.hibernate.sql.ast.tree.from

public Class LazyTableGroup

extends DelegatingTableGroup
Class Inheritance
Imports
java.util.ArrayList, .Collections, .List, java.util.function.Consumer, .Supplier, org.hibernate.engine.spi.SessionFactoryImplementor, org.hibernate.metamodel.mapping.ModelPart, .ValuedModelPart, org.hibernate.spi.NavigablePath, org.hibernate.sql.ast.spi.SqlAliasBase

The purpose of this table group is to defer creating the actual table group until it is really needed. If it is not needed, we can safely skip rendering it. This is useful for ToOneAttributeMapping and EntityCollectionPart, where we need a table group for the association, but aren't sure which columns are needed yet. Deferring initialization enables getting away with fewer joins in case only foreign key columns are used.
Author
Christian Beikov

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface

Field Summary

Modifier and TypeField and Description
private final boolean
private final boolean
private List<TableGroupJoin>
private final TableGroup
private final LazyTableGroup.ParentTableGroupUseChecker
private final TableGroupProducer
private final String
private final SqlAliasBase
private TableGroup
private Consumer<TableGroup>
private List<TableGroupJoin>
private final Supplier<TableGroup>

Constructor Summary

AccessConstructor and Description
public
LazyTableGroup(boolean canUseInnerJoins, NavigablePath navigablePath, boolean fetched, Supplier<TableGroup> tableGroupSupplier, LazyTableGroup.ParentTableGroupUseChecker parentTableGroupUseChecker, TableGroupProducer tableGroupProducer, String sourceAlias, SqlAliasBase sqlAliasBase, SessionFactoryImplementor sessionFactory, TableGroup parentTableGroup)

Deprecated as a consequence of SessionFactoryImplementor being deprecated.

Method Summary

Modifier and TypeMethod and Description
public void
addNestedTableGroupJoin(TableGroupJoin join)

Overrides org.hibernate.sql.ast.tree.from.DelegatingTableGroup.addNestedTableGroupJoin.

Implements org.hibernate.sql.ast.tree.from.TableGroup.addNestedTableGroupJoin.

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 as TableGroup( 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
public void
public void
public boolean
public ModelPart
public String
getGroupAlias()

Overrides org.hibernate.sql.ast.tree.from.DelegatingTableGroup.getGroupAlias.

Implements org.hibernate.sql.ast.tree.from.TableGroup.getGroupAlias.

If we want to use CTE for TableGroup rendering we will need to know the alias we can use for the group
public TableGroupProducer
public NavigablePath
public List<TableGroupJoin>
public String
public TableGroup
public List<TableGroupJoin>
public TableReference
getTableReference(NavigablePath
The path for which to look up the table reference, may be null
navigablePath
,
String
The table expression for which to look up the table reference
tableExpression
,
boolean
Whether to potentially create table reference joins for this table group
resolve
)

Overrides org.hibernate.sql.ast.tree.from.DelegatingTableGroup.getTableReference.

Implements org.hibernate.sql.ast.tree.from.ColumnReferenceQualifier.getTableReference.

Returns the table reference for the table expression, or null if not found.
public TableReference
public List<TableReferenceJoin>
public TableGroup
public boolean
public boolean
isInitialized()

Overrides org.hibernate.sql.ast.tree.from.DelegatingTableGroup.isInitialized.

Overrides default org.hibernate.sql.ast.tree.from.TableGroup.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.
public boolean
public boolean
public void
public void
public void
Inherited from org.hibernate.sql.ast.tree.from.DelegatingTableGroup:
acceptapplySqlSelectionscreateDomainResultcreateSqlSelectioncreateSqlSelectiongetColumnReferencegetPrimaryTableReferencegetSqlExpressionprependTableGroupJoin

Field Detail

canUseInnerJoinsback to summary
private final boolean canUseInnerJoins
fetchedback to summary
private final boolean fetched
nestedTableGroupJoinsback to summary
private List<TableGroupJoin> nestedTableGroupJoins
parentTableGroupback to summary
private final TableGroup parentTableGroup
parentTableGroupUseCheckerback to summary
private final LazyTableGroup.ParentTableGroupUseChecker parentTableGroupUseChecker
producerback to summary
private final TableGroupProducer producer
sourceAliasback to summary
private final String sourceAlias
sqlAliasBaseback to summary
private final SqlAliasBase sqlAliasBase
tableGroupback to summary
private TableGroup tableGroup
tableGroupConsumerback to summary
private Consumer<TableGroup> tableGroupConsumer
tableGroupJoinsback to summary
private List<TableGroupJoin> tableGroupJoins
tableGroupSupplierback to summary
private final Supplier<TableGroup> tableGroupSupplier

Constructor Detail

LazyTableGroupback to summary
public LazyTableGroup(boolean canUseInnerJoins, NavigablePath navigablePath, boolean fetched, Supplier<TableGroup> tableGroupSupplier, LazyTableGroup.ParentTableGroupUseChecker parentTableGroupUseChecker, TableGroupProducer tableGroupProducer, String sourceAlias, SqlAliasBase sqlAliasBase, SessionFactoryImplementor sessionFactory, TableGroup parentTableGroup)

Deprecated

as a consequence of SessionFactoryImplementor being deprecated. See corresponding docs for further information.

Method Detail

addNestedTableGroupJoinback to summary
public void addNestedTableGroupJoin(TableGroupJoin join)

Overrides org.hibernate.sql.ast.tree.from.DelegatingTableGroup.addNestedTableGroupJoin.

Implements org.hibernate.sql.ast.tree.from.TableGroup.addNestedTableGroupJoin.

Doc from org.hibernate.sql.ast.tree.from.TableGroup.addNestedTableGroupJoin.

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 as TableGroup( 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

Annotations
@Override
addTableGroupJoinback to summary
public void addTableGroupJoin(TableGroupJoin join)

Overrides org.hibernate.sql.ast.tree.from.DelegatingTableGroup.addTableGroupJoin.

Implements org.hibernate.sql.ast.tree.from.TableGroup.addTableGroupJoin.

Annotations
@Override
applyAffectedTableNamesback to summary
public void applyAffectedTableNames(Consumer<String> nameCollector)

Overrides org.hibernate.sql.ast.tree.from.DelegatingTableGroup.applyAffectedTableNames.

Implements org.hibernate.sql.ast.tree.from.TableGroup.applyAffectedTableNames.

Annotations
@Override
canUseInnerJoinsback to summary
public boolean canUseInnerJoins()

Overrides org.hibernate.sql.ast.tree.from.DelegatingTableGroup.canUseInnerJoins.

Implements org.hibernate.sql.ast.tree.from.TableGroup.canUseInnerJoins.

Annotations
@Override
getExpressionTypeback to summary
public ModelPart getExpressionType()

Overrides org.hibernate.sql.ast.tree.from.DelegatingTableGroup.getExpressionType.

Implements org.hibernate.query.sqm.sql.internal.SqmPathInterpretation.getExpressionType.

Doc from org.hibernate.sql.ast.tree.expression.Expression.getExpressionType.

The type for this expression

Annotations
@Override
getGroupAliasback to summary
public String getGroupAlias()

Overrides org.hibernate.sql.ast.tree.from.DelegatingTableGroup.getGroupAlias.

Implements org.hibernate.sql.ast.tree.from.TableGroup.getGroupAlias.

Doc from org.hibernate.sql.ast.tree.from.TableGroup.getGroupAlias.

If we want to use CTE for TableGroup rendering we will need to know the alias we can use for the group

Annotations
@Override
getModelPartback to summary
public TableGroupProducer getModelPart()

Overrides org.hibernate.sql.ast.tree.from.DelegatingTableGroup.getModelPart.

Implements org.hibernate.sql.ast.tree.from.TableGroup.getModelPart.

Annotations
@Override
getNavigablePathback to summary
public NavigablePath getNavigablePath()

Overrides org.hibernate.sql.ast.tree.from.DelegatingTableGroup.getNavigablePath.

Implements org.hibernate.sql.ast.tree.from.TableGroup.getNavigablePath.

Annotations
@Override
getNestedTableGroupJoinsback to summary
public List<TableGroupJoin> getNestedTableGroupJoins()

Overrides org.hibernate.sql.ast.tree.from.DelegatingTableGroup.getNestedTableGroupJoins.

Implements org.hibernate.sql.ast.tree.from.TableGroup.getNestedTableGroupJoins.

Annotations
@Override
getSourceAliasback to summary
public String getSourceAlias()

Overrides org.hibernate.sql.ast.tree.from.DelegatingTableGroup.getSourceAlias.

Implements org.hibernate.sql.ast.tree.from.TableGroup.getSourceAlias.

Annotations
@Override
getTableGroupback to summary
public TableGroup getTableGroup()

Implements abstract org.hibernate.sql.ast.tree.from.DelegatingTableGroup.getTableGroup.

Annotations
@Override
getTableGroupJoinsback to summary
public List<TableGroupJoin> getTableGroupJoins()

Overrides org.hibernate.sql.ast.tree.from.DelegatingTableGroup.getTableGroupJoins.

Implements org.hibernate.sql.ast.tree.from.TableGroup.getTableGroupJoins.

Annotations
@Override
getTableReferenceback to summary
public TableReference getTableReference(NavigablePath navigablePath, String tableExpression, boolean resolve)

Overrides org.hibernate.sql.ast.tree.from.DelegatingTableGroup.getTableReference.

Implements org.hibernate.sql.ast.tree.from.ColumnReferenceQualifier.getTableReference.

Doc from org.hibernate.sql.ast.tree.from.ColumnReferenceQualifier.getTableReference.

Returns the table reference for the table expression, or null if not found.

Parameters
navigablePath:NavigablePath

The path for which to look up the table reference, may be null

tableExpression:String

The table expression for which to look up the table reference

resolve:boolean

Whether to potentially create table reference joins for this table group

Annotations
@Override
getTableReferenceback to summary
public TableReference getTableReference(NavigablePath navigablePath, ValuedModelPart modelPart, String tableExpression, boolean resolve)

Overrides org.hibernate.sql.ast.tree.from.DelegatingTableGroup.getTableReference.

Overrides default org.hibernate.sql.ast.tree.from.ColumnReferenceQualifier.getTableReference.

Annotations
@Override
getTableReferenceJoinsback to summary
public List<TableReferenceJoin> getTableReferenceJoins()

Overrides org.hibernate.sql.ast.tree.from.DelegatingTableGroup.getTableReferenceJoins.

Implements org.hibernate.sql.ast.tree.from.TableGroup.getTableReferenceJoins.

Annotations
@Override
getUnderlyingTableGroupback to summary
public TableGroup getUnderlyingTableGroup()
isFetchedback to summary
public boolean isFetched()

Overrides org.hibernate.sql.ast.tree.from.DelegatingTableGroup.isFetched.

Overrides default org.hibernate.sql.ast.tree.from.TableGroup.isFetched.

Annotations
@Override
isInitializedback to summary
public boolean isInitialized()

Overrides org.hibernate.sql.ast.tree.from.DelegatingTableGroup.isInitialized.

Overrides default org.hibernate.sql.ast.tree.from.TableGroup.isInitialized.

Doc from org.hibernate.sql.ast.tree.from.TableGroup.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.

Annotations
@Override
isLateralback to summary
public boolean isLateral()

Overrides org.hibernate.sql.ast.tree.from.DelegatingTableGroup.isLateral.

Overrides default org.hibernate.sql.ast.tree.from.TableGroup.isLateral.

Annotations
@Override
isRealTableGroupback to summary
public boolean isRealTableGroup()

Overrides org.hibernate.sql.ast.tree.from.DelegatingTableGroup.isRealTableGroup.

Overrides default org.hibernate.sql.ast.tree.from.TableGroup.isRealTableGroup.

Annotations
@Override
setTableGroupInitializerCallbackback to summary
public void setTableGroupInitializerCallback(Consumer<TableGroup> tableGroupConsumer)
visitNestedTableGroupJoinsback to summary
public void visitNestedTableGroupJoins(Consumer<TableGroupJoin> consumer)

Overrides org.hibernate.sql.ast.tree.from.DelegatingTableGroup.visitNestedTableGroupJoins.

Implements org.hibernate.sql.ast.tree.from.TableGroup.visitNestedTableGroupJoins.

Annotations
@Override
visitTableGroupJoinsback to summary
public void visitTableGroupJoins(Consumer<TableGroupJoin> consumer)

Overrides org.hibernate.sql.ast.tree.from.DelegatingTableGroup.visitTableGroupJoins.

Implements org.hibernate.sql.ast.tree.from.TableGroup.visitTableGroupJoins.

Annotations
@Override
org.hibernate.sql.ast.tree.from back to summary

public Interface LazyTableGroup.ParentTableGroupUseChecker

Known Direct Implementers
org.hibernate.metamodel.mapping.internal.ManyToManyCollectionPart, org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping, org.hibernate.query.derived.AnonymousTupleEntityValuedModelPart

Method Summary

Modifier and TypeMethod and Description
public boolean
canUseParentTableGroup(TableGroupProducer producer, NavigablePath navigablePath, ValuedModelPart valuedModelPart)

Method Detail

canUseParentTableGroupback to summary
public boolean canUseParentTableGroup(TableGroupProducer producer, NavigablePath navigablePath, ValuedModelPart valuedModelPart)