use of org.hibernate.sql.ast.SqlAstJoinType in project hibernate-orm by hibernate.
the class PluralAttributeMappingImpl method createRootTableGroupJoin.
@Override
public TableGroup createRootTableGroupJoin(NavigablePath navigablePath, TableGroup lhs, String explicitSourceAlias, SqlAstJoinType requestedJoinType, boolean fetched, Consumer<Predicate> predicateConsumer, SqlAliasBaseGenerator aliasBaseGenerator, SqlExpressionResolver sqlExpressionResolver, FromClauseAccess fromClauseAccess, SqlAstCreationContext creationContext) {
final SqlAstJoinType joinType;
if (requestedJoinType == null) {
joinType = SqlAstJoinType.INNER;
} else {
joinType = requestedJoinType;
}
final CollectionPersister collectionDescriptor = getCollectionDescriptor();
final TableGroup tableGroup;
if (collectionDescriptor.isOneToMany()) {
tableGroup = createOneToManyTableGroup(lhs.canUseInnerJoins() && joinType == SqlAstJoinType.INNER, navigablePath, fetched, explicitSourceAlias, aliasBaseGenerator.createSqlAliasBase(getSqlAliasStem()), sqlExpressionResolver, fromClauseAccess, creationContext);
} else {
tableGroup = createCollectionTableGroup(lhs.canUseInnerJoins() && joinType == SqlAstJoinType.INNER, navigablePath, fetched, explicitSourceAlias, aliasBaseGenerator.createSqlAliasBase(getSqlAliasStem()), sqlExpressionResolver, fromClauseAccess, creationContext);
}
if (predicateConsumer != null) {
predicateConsumer.accept(getKeyDescriptor().generateJoinPredicate(lhs, tableGroup, sqlExpressionResolver, creationContext));
}
return tableGroup;
}
use of org.hibernate.sql.ast.SqlAstJoinType in project hibernate-orm by hibernate.
the class EntityCollectionPart method createTableGroupJoin.
@Override
public TableGroupJoin createTableGroupJoin(NavigablePath navigablePath, TableGroup collectionTableGroup, 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;
}
if (collectionDescriptor.isOneToMany() && nature == Nature.ELEMENT) {
// If this is a one-to-many, the element part is already available, so we return a TableGroupJoin "hull"
return new TableGroupJoin(navigablePath, joinType, ((OneToManyTableGroup) collectionTableGroup).getElementTableGroup(), null);
}
final LazyTableGroup lazyTableGroup = createRootTableGroupJoin(navigablePath, collectionTableGroup, explicitSourceAlias, requestedJoinType, fetched, null, aliasBaseGenerator, sqlExpressionResolver, fromClauseAccess, creationContext);
final TableGroupJoin join = new TableGroupJoin(navigablePath, joinType, lazyTableGroup, null);
lazyTableGroup.setTableGroupInitializerCallback(tableGroup -> join.applyPredicate(fkDescriptor.generateJoinPredicate(tableGroup.getPrimaryTableReference(), collectionTableGroup.resolveTableReference(fkDescriptor.getKeyTable()), sqlExpressionResolver, creationContext)));
return join;
}
Aggregations