use of org.hibernate.sql.ast.tree.from.TableGroup in project hibernate-orm by hibernate.
the class ImplicitModelPartResultBuilderEntity method buildResult.
@Override
public EntityResult buildResult(JdbcValuesMetadata jdbcResultsMetadata, int resultPosition, BiFunction<String, String, DynamicFetchBuilderLegacy> legacyFetchResolver, DomainResultCreationState domainResultCreationState) {
final DomainResultCreationStateImpl creationStateImpl = ResultsHelper.impl(domainResultCreationState);
creationStateImpl.disallowPositionalSelections();
final TableGroup tableGroup = creationStateImpl.getFromClauseAccess().resolveTableGroup(navigablePath, np -> {
if (navigablePath.getParent() != null) {
return creationStateImpl.getFromClauseAccess().getTableGroup(navigablePath.getParent());
}
return modelPart.getEntityMappingType().createRootTableGroup(// since this is only used for result set mappings, the canUseInnerJoins value is irrelevant.
true, navigablePath, null, null, creationStateImpl, creationStateImpl.getCreationContext());
});
return (EntityResult) modelPart.createDomainResult(navigablePath, tableGroup, null, domainResultCreationState);
}
use of org.hibernate.sql.ast.tree.from.TableGroup in project hibernate-orm by hibernate.
the class AbstractSqlAstTranslator method processTableGroupJoin.
protected void processTableGroupJoin(TableGroupJoin tableGroupJoin, List<TableGroupJoin> tableGroupJoinCollector) {
final TableGroup joinedGroup = tableGroupJoin.getJoinedGroup();
final TableGroup realTableGroup;
if (joinedGroup instanceof LazyTableGroup) {
realTableGroup = ((LazyTableGroup) joinedGroup).getUnderlyingTableGroup();
} else {
realTableGroup = joinedGroup;
}
if (realTableGroup instanceof VirtualTableGroup) {
processNestedTableGroupJoins(realTableGroup, tableGroupJoinCollector);
if (tableGroupJoinCollector != null) {
tableGroupJoinCollector.addAll(realTableGroup.getTableGroupJoins());
} else {
processTableGroupJoins(realTableGroup);
}
} else if (realTableGroup != null) {
renderTableGroupJoin(tableGroupJoin, tableGroupJoinCollector);
} else // A lazy table group, even if uninitialized, might contain table group joins
if (joinedGroup instanceof LazyTableGroup) {
processNestedTableGroupJoins(joinedGroup, tableGroupJoinCollector);
if (tableGroupJoinCollector != null) {
tableGroupJoinCollector.addAll(joinedGroup.getTableGroupJoins());
} else {
processTableGroupJoins(joinedGroup);
}
}
}
use of org.hibernate.sql.ast.tree.from.TableGroup in project hibernate-orm by hibernate.
the class AbstractSqlAstTranslator method hasNestedTableGroupsToRender.
protected boolean hasNestedTableGroupsToRender(List<TableGroupJoin> nestedTableGroupJoins) {
for (TableGroupJoin nestedTableGroupJoin : nestedTableGroupJoins) {
final TableGroup joinedGroup = nestedTableGroupJoin.getJoinedGroup();
final TableGroup realTableGroup;
if (joinedGroup instanceof LazyTableGroup) {
realTableGroup = ((LazyTableGroup) joinedGroup).getUnderlyingTableGroup();
} else {
realTableGroup = joinedGroup;
}
if (realTableGroup instanceof VirtualTableGroup) {
if (hasNestedTableGroupsToRender(realTableGroup.getNestedTableGroupJoins())) {
return true;
}
} else if (realTableGroup != null) {
return true;
}
}
return false;
}
use of org.hibernate.sql.ast.tree.from.TableGroup in project hibernate-orm by hibernate.
the class AbstractSqlAstTranslator method visitFromClause.
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// FROM clause
@Override
public void visitFromClause(FromClause fromClause) {
if (fromClause == null || fromClause.getRoots().isEmpty()) {
appendSql(getFromDualForSelectOnly());
} else {
appendSql(" from ");
try {
clauseStack.push(Clause.FROM);
String separator = NO_SEPARATOR;
for (TableGroup root : fromClause.getRoots()) {
// Skip virtual table group roots which we use for simple correlations
if (!(root instanceof VirtualTableGroup)) {
appendSql(separator);
renderRootTableGroup(root, null);
separator = COMA_SEPARATOR;
}
}
} finally {
clauseStack.pop();
}
}
}
use of org.hibernate.sql.ast.tree.from.TableGroup in project hibernate-orm by hibernate.
the class SimpleFromClauseAccessImpl method registerTableGroup.
@Override
public void registerTableGroup(NavigablePath navigablePath, TableGroup tableGroup) {
SqlTreeCreationLogger.LOGGER.debugf("Registration of TableGroup [%s] with identifierForTableGroup [%s] for NavigablePath [%s] ", tableGroup, tableGroup.getNavigablePath().getIdentifierForTableGroup(), navigablePath.getIdentifierForTableGroup());
final TableGroup previous = tableGroupMap.put(navigablePath, tableGroup);
if (previous != null) {
SqlTreeCreationLogger.LOGGER.debugf("Registration of TableGroup [%s] for NavigablePath [%s] overrode previous registration : %s", tableGroup, navigablePath, previous);
}
}
Aggregations