Search in sources :

Example 1 with VirtualTableGroup

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);
        }
    }
}
Also used : VirtualTableGroup(org.hibernate.sql.ast.tree.from.VirtualTableGroup) LazyTableGroup(org.hibernate.sql.ast.tree.from.LazyTableGroup) TableGroup(org.hibernate.sql.ast.tree.from.TableGroup) QueryPartTableGroup(org.hibernate.sql.ast.tree.from.QueryPartTableGroup) LazyTableGroup(org.hibernate.sql.ast.tree.from.LazyTableGroup) VirtualTableGroup(org.hibernate.sql.ast.tree.from.VirtualTableGroup)

Example 2 with VirtualTableGroup

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;
}
Also used : 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) QueryPartTableGroup(org.hibernate.sql.ast.tree.from.QueryPartTableGroup) LazyTableGroup(org.hibernate.sql.ast.tree.from.LazyTableGroup) VirtualTableGroup(org.hibernate.sql.ast.tree.from.VirtualTableGroup)

Example 3 with VirtualTableGroup

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();
        }
    }
}
Also used : VirtualTableGroup(org.hibernate.sql.ast.tree.from.VirtualTableGroup) LazyTableGroup(org.hibernate.sql.ast.tree.from.LazyTableGroup) TableGroup(org.hibernate.sql.ast.tree.from.TableGroup) QueryPartTableGroup(org.hibernate.sql.ast.tree.from.QueryPartTableGroup) VirtualTableGroup(org.hibernate.sql.ast.tree.from.VirtualTableGroup)

Aggregations

LazyTableGroup (org.hibernate.sql.ast.tree.from.LazyTableGroup)3 QueryPartTableGroup (org.hibernate.sql.ast.tree.from.QueryPartTableGroup)3 TableGroup (org.hibernate.sql.ast.tree.from.TableGroup)3 VirtualTableGroup (org.hibernate.sql.ast.tree.from.VirtualTableGroup)3 TableGroupJoin (org.hibernate.sql.ast.tree.from.TableGroupJoin)1