Search in sources :

Example 6 with SqlAstJoinType

use of org.hibernate.sql.ast.SqlAstJoinType 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)

Example 7 with SqlAstJoinType

use of org.hibernate.sql.ast.SqlAstJoinType in project hibernate-orm by hibernate.

the class DiscriminatedCollectionPart 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)

Example 8 with SqlAstJoinType

use of org.hibernate.sql.ast.SqlAstJoinType in project hibernate-orm by hibernate.

the class AbstractCompositeIdentifierMapping 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) SqlAstJoinType(org.hibernate.sql.ast.SqlAstJoinType)

Example 9 with SqlAstJoinType

use of org.hibernate.sql.ast.SqlAstJoinType in project hibernate-orm by hibernate.

the class BaseSqmToSqlAstConverter method consumeEntityJoin.

private TableGroup consumeEntityJoin(SqmEntityJoin<?> sqmJoin, TableGroup lhsTableGroup, boolean transitive) {
    final EntityPersister entityDescriptor = resolveEntityPersister(sqmJoin.getReferencedPathSource());
    final SqlAstJoinType correspondingSqlJoinType = sqmJoin.getSqmJoinType().getCorrespondingSqlJoinType();
    final TableGroup tableGroup = entityDescriptor.createRootTableGroup(correspondingSqlJoinType == SqlAstJoinType.INNER || correspondingSqlJoinType == SqlAstJoinType.CROSS, sqmJoin.getNavigablePath(), sqmJoin.getExplicitAlias(), () -> predicate -> additionalRestrictions = SqlAstTreeHelper.combinePredicates(additionalRestrictions, predicate), this, getCreationContext());
    getFromClauseIndex().register(sqmJoin, tableGroup);
    final TableGroupJoin tableGroupJoin = new TableGroupJoin(sqmJoin.getNavigablePath(), correspondingSqlJoinType, tableGroup, null);
    // add any additional join restrictions
    if (sqmJoin.getJoinPredicate() != null) {
        final SqmJoin<?, ?> oldJoin = currentlyProcessingJoin;
        currentlyProcessingJoin = sqmJoin;
        tableGroupJoin.applyPredicate(visitNestedTopLevelPredicate(sqmJoin.getJoinPredicate()));
        currentlyProcessingJoin = oldJoin;
    }
    // Note that we add the entity join after processing the predicate because implicit joins needed in there
    // can be just ordered right before the entity join without changing the semantics
    lhsTableGroup.addTableGroupJoin(tableGroupJoin);
    if (transitive) {
        consumeExplicitJoins(sqmJoin, tableGroupJoin.getJoinedGroup());
    }
    return tableGroup;
}
Also used : EntityPersister(org.hibernate.persister.entity.EntityPersister) SingleTableEntityPersister(org.hibernate.persister.entity.SingleTableEntityPersister) AbstractEntityPersister(org.hibernate.persister.entity.AbstractEntityPersister) TableGroupJoin(org.hibernate.sql.ast.tree.from.TableGroupJoin) VirtualTableGroup(org.hibernate.sql.ast.tree.from.VirtualTableGroup) LazyTableGroup(org.hibernate.sql.ast.tree.from.LazyTableGroup) TableGroup(org.hibernate.sql.ast.tree.from.TableGroup) CorrelatedTableGroup(org.hibernate.sql.ast.tree.from.CorrelatedTableGroup) CorrelatedPluralTableGroup(org.hibernate.sql.ast.tree.from.CorrelatedPluralTableGroup) PluralTableGroup(org.hibernate.sql.ast.tree.from.PluralTableGroup) QueryPartTableGroup(org.hibernate.sql.ast.tree.from.QueryPartTableGroup) SqlAstJoinType(org.hibernate.sql.ast.SqlAstJoinType)

Example 10 with SqlAstJoinType

use of org.hibernate.sql.ast.SqlAstJoinType in project hibernate-orm by hibernate.

the class EmbeddedAttributeMapping 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 = requestedJoinType == null ? SqlAstJoinType.INNER : 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

SqlAstJoinType (org.hibernate.sql.ast.SqlAstJoinType)12 TableGroup (org.hibernate.sql.ast.tree.from.TableGroup)10 TableGroupJoin (org.hibernate.sql.ast.tree.from.TableGroupJoin)9 LazyTableGroup (org.hibernate.sql.ast.tree.from.LazyTableGroup)5 StandardVirtualTableGroup (org.hibernate.sql.ast.tree.from.StandardVirtualTableGroup)5 PluralTableGroup (org.hibernate.sql.ast.tree.from.PluralTableGroup)4 NavigablePath (org.hibernate.query.spi.NavigablePath)3 SqlAliasBase (org.hibernate.sql.ast.spi.SqlAliasBase)3 CorrelatedTableGroup (org.hibernate.sql.ast.tree.from.CorrelatedTableGroup)3 TableReference (org.hibernate.sql.ast.tree.from.TableReference)3 EmbeddableValuedModelPart (org.hibernate.metamodel.mapping.EmbeddableValuedModelPart)2 AbstractEntityPersister (org.hibernate.persister.entity.AbstractEntityPersister)2 EntityPersister (org.hibernate.persister.entity.EntityPersister)2 TreatedNavigablePath (org.hibernate.query.spi.TreatedNavigablePath)2 EntityIdentifierNavigablePath (org.hibernate.query.sqm.spi.EntityIdentifierNavigablePath)2 MappedByTableGroup (org.hibernate.sql.ast.tree.from.MappedByTableGroup)2 StandardTableGroup (org.hibernate.sql.ast.tree.from.StandardTableGroup)2 TableGroupProducer (org.hibernate.sql.ast.tree.from.TableGroupProducer)2 Predicate (org.hibernate.sql.ast.tree.predicate.Predicate)2 ArrayList (java.util.ArrayList)1