Search in sources :

Example 6 with TableGroupJoin

use of org.hibernate.sql.ast.tree.from.TableGroupJoin in project hibernate-orm by hibernate.

the class EmbeddedCollectionPart method createTableGroupJoin.

@Override
public TableGroupJoin createTableGroupJoin(NavigablePath navigablePath, TableGroup lhs, String explicitSourceAlias, SqlAstJoinType requestedJoinType, boolean fetched, boolean addsPredicate, SqlAliasBaseGenerator aliasBaseGenerator, SqlExpressionResolver sqlExpressionResolver, FromClauseAccess fromClauseAccess, SqlAstCreationContext creationContext) {
    final SqlAstJoinType joinType;
    if (requestedJoinType == null) {
        joinType = SqlAstJoinType.INNER;
    } else {
        joinType = requestedJoinType;
    }
    final TableGroup tableGroup = createRootTableGroupJoin(navigablePath, lhs, explicitSourceAlias, requestedJoinType, fetched, null, aliasBaseGenerator, sqlExpressionResolver, fromClauseAccess, creationContext);
    return new TableGroupJoin(navigablePath, joinType, tableGroup, null);
}
Also used : TableGroupJoin(org.hibernate.sql.ast.tree.from.TableGroupJoin) StandardVirtualTableGroup(org.hibernate.sql.ast.tree.from.StandardVirtualTableGroup) TableGroup(org.hibernate.sql.ast.tree.from.TableGroup) PluralTableGroup(org.hibernate.sql.ast.tree.from.PluralTableGroup) SqlAstJoinType(org.hibernate.sql.ast.SqlAstJoinType)

Example 7 with TableGroupJoin

use of org.hibernate.sql.ast.tree.from.TableGroupJoin in project hibernate-orm by hibernate.

the class PluralAttributeMappingImpl method createTableGroupJoin.

@Override
public TableGroupJoin createTableGroupJoin(NavigablePath navigablePath, TableGroup lhs, String explicitSourceAlias, SqlAstJoinType requestedJoinType, boolean fetched, boolean addsPredicate, SqlAliasBaseGenerator aliasBaseGenerator, SqlExpressionResolver sqlExpressionResolver, FromClauseAccess fromClauseAccess, SqlAstCreationContext creationContext) {
    final SqlAstJoinType joinType;
    if (requestedJoinType == null) {
        joinType = SqlAstJoinType.INNER;
    } else {
        joinType = requestedJoinType;
    }
    final java.util.List<Predicate> predicates = new ArrayList<>(2);
    final TableGroup tableGroup = createRootTableGroupJoin(navigablePath, lhs, explicitSourceAlias, requestedJoinType, fetched, predicates::add, aliasBaseGenerator, sqlExpressionResolver, fromClauseAccess, creationContext);
    final TableGroupJoin tableGroupJoin = new TableGroupJoin(navigablePath, joinType, tableGroup, null);
    predicates.forEach(tableGroupJoin::applyPredicate);
    return tableGroupJoin;
}
Also used : TableGroupJoin(org.hibernate.sql.ast.tree.from.TableGroupJoin) CollectionTableGroup(org.hibernate.sql.ast.tree.from.CollectionTableGroup) OneToManyTableGroup(org.hibernate.sql.ast.tree.from.OneToManyTableGroup) TableGroup(org.hibernate.sql.ast.tree.from.TableGroup) SqlAstJoinType(org.hibernate.sql.ast.SqlAstJoinType) ArrayList(java.util.ArrayList) Predicate(org.hibernate.sql.ast.tree.predicate.Predicate)

Example 8 with TableGroupJoin

use of org.hibernate.sql.ast.tree.from.TableGroupJoin in project hibernate-orm by hibernate.

the class PluralAttributeMappingImpl method createCollectionTableGroup.

private TableGroup createCollectionTableGroup(boolean canUseInnerJoins, NavigablePath navigablePath, boolean fetched, String sourceAlias, SqlAliasBase sqlAliasBase, SqlExpressionResolver sqlExpressionResolver, FromClauseAccess fromClauseAccess, SqlAstCreationContext creationContext) {
    assert !getCollectionDescriptor().isOneToMany();
    final String collectionTableName = ((Joinable) collectionDescriptor).getTableName();
    final TableReference collectionTableReference = new NamedTableReference(collectionTableName, sqlAliasBase.generateNewAlias(), true, creationContext.getSessionFactory());
    final CollectionTableGroup tableGroup = new CollectionTableGroup(canUseInnerJoins, navigablePath, this, fetched, sourceAlias, collectionTableReference, true, sqlAliasBase, s -> false, null, creationContext.getSessionFactory());
    if (elementDescriptor instanceof TableGroupJoinProducer) {
        final TableGroupJoin tableGroupJoin = ((TableGroupJoinProducer) elementDescriptor).createTableGroupJoin(navigablePath.append(CollectionPart.Nature.ELEMENT.getName()), tableGroup, null, SqlAstJoinType.INNER, fetched, false, stem -> sqlAliasBase, sqlExpressionResolver, fromClauseAccess, creationContext);
        tableGroup.registerElementTableGroup(tableGroupJoin);
    }
    if (indexDescriptor instanceof TableGroupJoinProducer) {
        final TableGroupJoin tableGroupJoin = ((TableGroupJoinProducer) indexDescriptor).createTableGroupJoin(navigablePath.append(CollectionPart.Nature.INDEX.getName()), tableGroup, null, SqlAstJoinType.INNER, fetched, false, stem -> sqlAliasBase, sqlExpressionResolver, fromClauseAccess, creationContext);
        tableGroup.registerIndexTableGroup(tableGroupJoin);
    }
    return tableGroup;
}
Also used : TableGroupJoin(org.hibernate.sql.ast.tree.from.TableGroupJoin) TableReference(org.hibernate.sql.ast.tree.from.TableReference) NamedTableReference(org.hibernate.sql.ast.tree.from.NamedTableReference) NamedTableReference(org.hibernate.sql.ast.tree.from.NamedTableReference) TableGroupJoinProducer(org.hibernate.sql.ast.tree.from.TableGroupJoinProducer) Joinable(org.hibernate.persister.entity.Joinable) CollectionTableGroup(org.hibernate.sql.ast.tree.from.CollectionTableGroup)

Example 9 with TableGroupJoin

use of org.hibernate.sql.ast.tree.from.TableGroupJoin in project hibernate-orm by hibernate.

the class PluralAttributeMappingImpl method createOneToManyTableGroup.

private TableGroup createOneToManyTableGroup(boolean canUseInnerJoins, NavigablePath navigablePath, boolean fetched, String sourceAlias, SqlAliasBase sqlAliasBase, SqlExpressionResolver sqlExpressionResolver, FromClauseAccess fromClauseAccess, SqlAstCreationContext creationContext) {
    final TableGroup elementTableGroup = ((EntityCollectionPart) elementDescriptor).createTableGroupInternal(canUseInnerJoins, navigablePath.append(CollectionPart.Nature.ELEMENT.getName()), fetched, sourceAlias, sqlAliasBase, sqlExpressionResolver, creationContext);
    final OneToManyTableGroup tableGroup = new OneToManyTableGroup(this, elementTableGroup, creationContext.getSessionFactory());
    if (indexDescriptor instanceof TableGroupJoinProducer) {
        final TableGroupJoin tableGroupJoin = ((TableGroupJoinProducer) indexDescriptor).createTableGroupJoin(navigablePath.append(CollectionPart.Nature.INDEX.getName()), tableGroup, null, SqlAstJoinType.INNER, fetched, false, stem -> sqlAliasBase, sqlExpressionResolver, fromClauseAccess, creationContext);
        tableGroup.registerIndexTableGroup(tableGroupJoin);
    }
    return tableGroup;
}
Also used : TableGroupJoin(org.hibernate.sql.ast.tree.from.TableGroupJoin) OneToManyTableGroup(org.hibernate.sql.ast.tree.from.OneToManyTableGroup) CollectionTableGroup(org.hibernate.sql.ast.tree.from.CollectionTableGroup) OneToManyTableGroup(org.hibernate.sql.ast.tree.from.OneToManyTableGroup) TableGroup(org.hibernate.sql.ast.tree.from.TableGroup) TableGroupJoinProducer(org.hibernate.sql.ast.tree.from.TableGroupJoinProducer)

Example 10 with TableGroupJoin

use of org.hibernate.sql.ast.tree.from.TableGroupJoin in project hibernate-orm by hibernate.

the class DiscriminatedAssociationAttributeMapping method createTableGroupJoin.

@Override
public TableGroupJoin createTableGroupJoin(NavigablePath navigablePath, TableGroup lhs, String explicitSourceAlias, SqlAstJoinType requestedJoinType, boolean fetched, boolean addsPredicate, SqlAliasBaseGenerator aliasBaseGenerator, SqlExpressionResolver sqlExpressionResolver, FromClauseAccess fromClauseAccess, SqlAstCreationContext creationContext) {
    final SqlAstJoinType joinType;
    if (requestedJoinType == null) {
        joinType = SqlAstJoinType.INNER;
    } else {
        joinType = requestedJoinType;
    }
    final TableGroup tableGroup = createRootTableGroupJoin(navigablePath, lhs, explicitSourceAlias, requestedJoinType, fetched, null, aliasBaseGenerator, sqlExpressionResolver, fromClauseAccess, creationContext);
    return new TableGroupJoin(navigablePath, joinType, tableGroup);
}
Also used : TableGroupJoin(org.hibernate.sql.ast.tree.from.TableGroupJoin) StandardVirtualTableGroup(org.hibernate.sql.ast.tree.from.StandardVirtualTableGroup) TableGroup(org.hibernate.sql.ast.tree.from.TableGroup) SqlAstJoinType(org.hibernate.sql.ast.SqlAstJoinType)

Aggregations

TableGroupJoin (org.hibernate.sql.ast.tree.from.TableGroupJoin)39 TableGroup (org.hibernate.sql.ast.tree.from.TableGroup)34 LazyTableGroup (org.hibernate.sql.ast.tree.from.LazyTableGroup)17 PluralAttributeMapping (org.hibernate.metamodel.mapping.PluralAttributeMapping)14 PluralTableGroup (org.hibernate.sql.ast.tree.from.PluralTableGroup)14 NavigablePath (org.hibernate.query.spi.NavigablePath)13 SqlAstJoinType (org.hibernate.sql.ast.SqlAstJoinType)13 EntityPersister (org.hibernate.persister.entity.EntityPersister)11 CorrelatedTableGroup (org.hibernate.sql.ast.tree.from.CorrelatedTableGroup)11 QueryPartTableGroup (org.hibernate.sql.ast.tree.from.QueryPartTableGroup)10 TableGroupJoinProducer (org.hibernate.sql.ast.tree.from.TableGroupJoinProducer)10 VirtualTableGroup (org.hibernate.sql.ast.tree.from.VirtualTableGroup)10 Fetch (org.hibernate.sql.results.graph.Fetch)10 CorrelatedPluralTableGroup (org.hibernate.sql.ast.tree.from.CorrelatedPluralTableGroup)9 SelectStatement (org.hibernate.sql.ast.tree.select.SelectStatement)9 EntityValuedModelPart (org.hibernate.metamodel.mapping.EntityValuedModelPart)8 AbstractEntityPersister (org.hibernate.persister.entity.AbstractEntityPersister)8 DomainResult (org.hibernate.sql.results.graph.DomainResult)8 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)7 ModelPart (org.hibernate.metamodel.mapping.ModelPart)7