use of org.hibernate.sql.ast.tree.from.VirtualTableGroup 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.VirtualTableGroup 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.VirtualTableGroup 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();
}
}
}
Aggregations