Search in sources :

Example 1 with DerivedTableReference

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

the class AbstractSqlAstTranslator method renderPrimaryTableReference.

protected boolean renderPrimaryTableReference(TableGroup tableGroup, LockMode lockMode) {
    final TableReference tableReference = tableGroup.getPrimaryTableReference();
    if (tableReference instanceof NamedTableReference) {
        return renderNamedTableReference((NamedTableReference) tableReference, lockMode);
    }
    final DerivedTableReference derivedTableReference = (DerivedTableReference) tableReference;
    if (derivedTableReference.isLateral()) {
        if (getDialect().supportsLateral()) {
            appendSql("lateral");
        } else if (tableReference instanceof QueryPartTableReference) {
            final QueryPartTableReference queryPartTableReference = (QueryPartTableReference) tableReference;
            final QueryPart emulationQueryPart = stripToSelectClause(queryPartTableReference.getQueryPart());
            final QueryPartTableReference emulationTableReference = new QueryPartTableReference(emulationQueryPart, tableReference.getIdentificationVariable(), queryPartTableReference.getColumnNames(), false, sessionFactory);
            emulationTableReference.accept(this);
            return false;
        }
    }
    tableReference.accept(this);
    return false;
}
Also used : NamedTableReference(org.hibernate.sql.ast.tree.from.NamedTableReference) DerivedTableReference(org.hibernate.sql.ast.tree.from.DerivedTableReference) ValuesTableReference(org.hibernate.sql.ast.tree.from.ValuesTableReference) FunctionTableReference(org.hibernate.sql.ast.tree.from.FunctionTableReference) TableReference(org.hibernate.sql.ast.tree.from.TableReference) QueryPartTableReference(org.hibernate.sql.ast.tree.from.QueryPartTableReference) NamedTableReference(org.hibernate.sql.ast.tree.from.NamedTableReference) QueryPart(org.hibernate.sql.ast.tree.select.QueryPart) DerivedTableReference(org.hibernate.sql.ast.tree.from.DerivedTableReference) QueryPartTableReference(org.hibernate.sql.ast.tree.from.QueryPartTableReference)

Example 2 with DerivedTableReference

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

the class SpannerSqlAstTranslator method renderPrimaryTableReference.

@Override
protected boolean renderPrimaryTableReference(TableGroup tableGroup, LockMode lockMode) {
    final TableReference tableReference = tableGroup.getPrimaryTableReference();
    if (tableReference instanceof NamedTableReference) {
        return renderNamedTableReference((NamedTableReference) tableReference, lockMode);
    }
    final DerivedTableReference derivedTableReference = (DerivedTableReference) tableReference;
    final boolean correlated = derivedTableReference.isLateral();
    final boolean oldCorrelated = this.correlated;
    if (correlated) {
        this.correlated = true;
        appendSql("unnest(array");
    }
    tableReference.accept(this);
    if (correlated) {
        this.correlated = oldCorrelated;
        appendSql(CLOSE_PARENTHESIS);
    }
    return false;
}
Also used : DerivedTableReference(org.hibernate.sql.ast.tree.from.DerivedTableReference) TableReference(org.hibernate.sql.ast.tree.from.TableReference) NamedTableReference(org.hibernate.sql.ast.tree.from.NamedTableReference) NamedTableReference(org.hibernate.sql.ast.tree.from.NamedTableReference) DerivedTableReference(org.hibernate.sql.ast.tree.from.DerivedTableReference)

Aggregations

DerivedTableReference (org.hibernate.sql.ast.tree.from.DerivedTableReference)2 NamedTableReference (org.hibernate.sql.ast.tree.from.NamedTableReference)2 TableReference (org.hibernate.sql.ast.tree.from.TableReference)2 FunctionTableReference (org.hibernate.sql.ast.tree.from.FunctionTableReference)1 QueryPartTableReference (org.hibernate.sql.ast.tree.from.QueryPartTableReference)1 ValuesTableReference (org.hibernate.sql.ast.tree.from.ValuesTableReference)1 QueryPart (org.hibernate.sql.ast.tree.select.QueryPart)1