Search in sources :

Example 1 with ValuesTableReference

use of org.hibernate.sql.ast.tree.from.ValuesTableReference in project hibernate-orm by hibernate.

the class SqlTreePrinter method logTableGroupDetails.

private void logTableGroupDetails(TableGroup tableGroup) {
    if (tableGroup instanceof LazyTableGroup) {
        TableGroup underlyingTableGroup = ((LazyTableGroup) tableGroup).getUnderlyingTableGroup();
        if (underlyingTableGroup != null) {
            logTableGroupDetails(underlyingTableGroup);
        }
        return;
    }
    if (tableGroup.getPrimaryTableReference() instanceof NamedTableReference) {
        logWithIndentation("primaryTableReference : %s as %s", tableGroup.getPrimaryTableReference().getTableId(), tableGroup.getPrimaryTableReference().getIdentificationVariable());
    } else {
        if (tableGroup.getPrimaryTableReference() instanceof ValuesTableReference) {
            logWithIndentation("primaryTableReference : values (..) as %s", tableGroup.getPrimaryTableReference().getIdentificationVariable());
        } else if (tableGroup.getPrimaryTableReference() instanceof FunctionTableReference) {
            logWithIndentation("primaryTableReference : %s(...) as %s", ((FunctionTableReference) tableGroup.getPrimaryTableReference()).getFunctionExpression().getFunctionName(), tableGroup.getPrimaryTableReference().getIdentificationVariable());
        } else {
            logNode("PrimaryTableReference as " + tableGroup.getPrimaryTableReference().getIdentificationVariable(), () -> {
                QueryPart queryPart = ((QueryPartTableReference) tableGroup.getPrimaryTableReference()).getQueryPart();
                visitQueryPart(queryPart);
            });
        }
    }
    final List<TableReferenceJoin> tableReferenceJoins = tableGroup.getTableReferenceJoins();
    if (!tableReferenceJoins.isEmpty()) {
        logNode("TableReferenceJoins", () -> {
            for (TableReferenceJoin join : tableReferenceJoins) {
                logWithIndentation("%s join %s as %s", join.getJoinType().getText(), join.getJoinedTableReference().getTableExpression(), join.getJoinedTableReference().getIdentificationVariable());
            }
        });
    }
    final List<TableGroupJoin> nestedTableGroupJoins = tableGroup.getNestedTableGroupJoins();
    if (!nestedTableGroupJoins.isEmpty()) {
        logNode("NestedTableGroupJoins", () -> tableGroup.visitNestedTableGroupJoins(this::visitTableGroupJoin));
    }
    final List<TableGroupJoin> tableGroupJoins = tableGroup.getTableGroupJoins();
    if (!tableGroupJoins.isEmpty()) {
        logNode("TableGroupJoins", () -> tableGroup.visitTableGroupJoins(this::visitTableGroupJoin));
    }
}
Also used : TableGroupJoin(org.hibernate.sql.ast.tree.from.TableGroupJoin) LazyTableGroup(org.hibernate.sql.ast.tree.from.LazyTableGroup) TableGroup(org.hibernate.sql.ast.tree.from.TableGroup) NamedTableReference(org.hibernate.sql.ast.tree.from.NamedTableReference) LazyTableGroup(org.hibernate.sql.ast.tree.from.LazyTableGroup) FunctionTableReference(org.hibernate.sql.ast.tree.from.FunctionTableReference) QueryPart(org.hibernate.sql.ast.tree.select.QueryPart) ValuesTableReference(org.hibernate.sql.ast.tree.from.ValuesTableReference) TableReferenceJoin(org.hibernate.sql.ast.tree.from.TableReferenceJoin)

Aggregations

FunctionTableReference (org.hibernate.sql.ast.tree.from.FunctionTableReference)1 LazyTableGroup (org.hibernate.sql.ast.tree.from.LazyTableGroup)1 NamedTableReference (org.hibernate.sql.ast.tree.from.NamedTableReference)1 TableGroup (org.hibernate.sql.ast.tree.from.TableGroup)1 TableGroupJoin (org.hibernate.sql.ast.tree.from.TableGroupJoin)1 TableReferenceJoin (org.hibernate.sql.ast.tree.from.TableReferenceJoin)1 ValuesTableReference (org.hibernate.sql.ast.tree.from.ValuesTableReference)1 QueryPart (org.hibernate.sql.ast.tree.select.QueryPart)1