Search in sources :

Example 86 with Expression

use of org.hibernate.sql.ast.tree.expression.Expression in project hibernate-orm by hibernate.

the class AbstractSqlAstTranslator method renderCommaSeparatedSelectExpression.

protected final void renderCommaSeparatedSelectExpression(Iterable<? extends SqlAstNode> expressions) {
    String separator = NO_SEPARATOR;
    for (SqlAstNode expression : expressions) {
        final SqlTuple sqlTuple = SqlTupleContainer.getSqlTuple(expression);
        if (sqlTuple != null) {
            for (Expression e : sqlTuple.getExpressions()) {
                appendSql(separator);
                renderSelectExpression(e);
                separator = COMA_SEPARATOR;
            }
        } else if (expression instanceof Expression) {
            appendSql(separator);
            renderSelectExpression((Expression) expression);
        } else {
            appendSql(separator);
            expression.accept(this);
        }
        separator = COMA_SEPARATOR;
    }
}
Also used : Expression(org.hibernate.sql.ast.tree.expression.Expression) BinaryArithmeticExpression(org.hibernate.sql.ast.tree.expression.BinaryArithmeticExpression) SelfRenderingExpression(org.hibernate.sql.ast.tree.expression.SelfRenderingExpression) OrderedSetAggregateFunctionExpression(org.hibernate.sql.ast.tree.expression.OrderedSetAggregateFunctionExpression) CaseSimpleExpression(org.hibernate.sql.ast.tree.expression.CaseSimpleExpression) SqlSelectionExpression(org.hibernate.sql.ast.tree.expression.SqlSelectionExpression) CaseSearchedExpression(org.hibernate.sql.ast.tree.expression.CaseSearchedExpression) ModifiedSubQueryExpression(org.hibernate.sql.ast.tree.expression.ModifiedSubQueryExpression) SqlTuple(org.hibernate.sql.ast.tree.expression.SqlTuple) SqlAstNode(org.hibernate.sql.ast.tree.SqlAstNode)

Example 87 with Expression

use of org.hibernate.sql.ast.tree.expression.Expression in project hibernate-orm by hibernate.

the class AbstractSqlAstWalker method visitQuerySpec.

@Override
public void visitQuerySpec(QuerySpec querySpec) {
    querySpec.getSelectClause().accept(this);
    querySpec.getFromClause().accept(this);
    if (querySpec.getWhereClauseRestrictions() != null) {
        querySpec.getWhereClauseRestrictions().accept(this);
    }
    for (Expression groupByClauseExpression : querySpec.getGroupByClauseExpressions()) {
        groupByClauseExpression.accept(this);
    }
    if (querySpec.getHavingClauseRestrictions() != null) {
        querySpec.getHavingClauseRestrictions().accept(this);
    }
    visitOffsetFetchClause(querySpec);
}
Also used : OrderedSetAggregateFunctionExpression(org.hibernate.sql.ast.tree.expression.OrderedSetAggregateFunctionExpression) Expression(org.hibernate.sql.ast.tree.expression.Expression) CaseSimpleExpression(org.hibernate.sql.ast.tree.expression.CaseSimpleExpression) BinaryArithmeticExpression(org.hibernate.sql.ast.tree.expression.BinaryArithmeticExpression) SqlSelectionExpression(org.hibernate.sql.ast.tree.expression.SqlSelectionExpression) FunctionExpression(org.hibernate.sql.ast.tree.expression.FunctionExpression) CaseSearchedExpression(org.hibernate.sql.ast.tree.expression.CaseSearchedExpression) AggregateFunctionExpression(org.hibernate.sql.ast.tree.expression.AggregateFunctionExpression) ModifiedSubQueryExpression(org.hibernate.sql.ast.tree.expression.ModifiedSubQueryExpression) SelfRenderingExpression(org.hibernate.sql.ast.tree.expression.SelfRenderingExpression)

Example 88 with Expression

use of org.hibernate.sql.ast.tree.expression.Expression in project hibernate-orm by hibernate.

the class ExpressionReplacementWalker method visitRelationalPredicate.

@Override
public void visitRelationalPredicate(ComparisonPredicate comparisonPredicate) {
    final Expression lhs = replaceExpression(comparisonPredicate.getLeftHandExpression());
    final Expression rhs = replaceExpression(comparisonPredicate.getRightHandExpression());
    if (lhs != comparisonPredicate.getLeftHandExpression() || rhs != comparisonPredicate.getRightHandExpression()) {
        returnedNode = new ComparisonPredicate(lhs, comparisonPredicate.getOperator(), rhs, comparisonPredicate.getExpressionType());
    } else {
        returnedNode = comparisonPredicate;
    }
}
Also used : Expression(org.hibernate.sql.ast.tree.expression.Expression) CaseSimpleExpression(org.hibernate.sql.ast.tree.expression.CaseSimpleExpression) BinaryArithmeticExpression(org.hibernate.sql.ast.tree.expression.BinaryArithmeticExpression) SqlSelectionExpression(org.hibernate.sql.ast.tree.expression.SqlSelectionExpression) CaseSearchedExpression(org.hibernate.sql.ast.tree.expression.CaseSearchedExpression) ModifiedSubQueryExpression(org.hibernate.sql.ast.tree.expression.ModifiedSubQueryExpression) SelfRenderingExpression(org.hibernate.sql.ast.tree.expression.SelfRenderingExpression) ComparisonPredicate(org.hibernate.sql.ast.tree.predicate.ComparisonPredicate)

Example 89 with Expression

use of org.hibernate.sql.ast.tree.expression.Expression in project hibernate-orm by hibernate.

the class ExpressionReplacementWalker method visitBetweenPredicate.

@Override
public void visitBetweenPredicate(BetweenPredicate betweenPredicate) {
    final Expression expression = replaceExpression(betweenPredicate.getExpression());
    final Expression lowerBound = replaceExpression(betweenPredicate.getLowerBound());
    final Expression upperBound = replaceExpression(betweenPredicate.getUpperBound());
    if (expression != betweenPredicate.getExpression() || lowerBound != betweenPredicate.getLowerBound() || upperBound != betweenPredicate.getUpperBound()) {
        returnedNode = new BetweenPredicate(expression, lowerBound, upperBound, betweenPredicate.isNegated(), betweenPredicate.getExpressionType());
    } else {
        returnedNode = betweenPredicate;
    }
}
Also used : BetweenPredicate(org.hibernate.sql.ast.tree.predicate.BetweenPredicate) Expression(org.hibernate.sql.ast.tree.expression.Expression) CaseSimpleExpression(org.hibernate.sql.ast.tree.expression.CaseSimpleExpression) BinaryArithmeticExpression(org.hibernate.sql.ast.tree.expression.BinaryArithmeticExpression) SqlSelectionExpression(org.hibernate.sql.ast.tree.expression.SqlSelectionExpression) CaseSearchedExpression(org.hibernate.sql.ast.tree.expression.CaseSearchedExpression) ModifiedSubQueryExpression(org.hibernate.sql.ast.tree.expression.ModifiedSubQueryExpression) SelfRenderingExpression(org.hibernate.sql.ast.tree.expression.SelfRenderingExpression)

Example 90 with Expression

use of org.hibernate.sql.ast.tree.expression.Expression in project hibernate-orm by hibernate.

the class ExpressionReplacementWalker method visitInSubQueryPredicate.

@Override
public void visitInSubQueryPredicate(InSubQueryPredicate inSubQueryPredicate) {
    final Expression testExpression = replaceExpression(inSubQueryPredicate.getTestExpression());
    final QueryPart subQuery = replaceExpression(inSubQueryPredicate.getSubQuery());
    if (testExpression != inSubQueryPredicate.getTestExpression() || subQuery != inSubQueryPredicate.getSubQuery()) {
        returnedNode = new InSubQueryPredicate(testExpression, subQuery, inSubQueryPredicate.isNegated(), inSubQueryPredicate.getExpressionType());
    } else {
        returnedNode = inSubQueryPredicate;
    }
}
Also used : Expression(org.hibernate.sql.ast.tree.expression.Expression) CaseSimpleExpression(org.hibernate.sql.ast.tree.expression.CaseSimpleExpression) BinaryArithmeticExpression(org.hibernate.sql.ast.tree.expression.BinaryArithmeticExpression) SqlSelectionExpression(org.hibernate.sql.ast.tree.expression.SqlSelectionExpression) CaseSearchedExpression(org.hibernate.sql.ast.tree.expression.CaseSearchedExpression) ModifiedSubQueryExpression(org.hibernate.sql.ast.tree.expression.ModifiedSubQueryExpression) SelfRenderingExpression(org.hibernate.sql.ast.tree.expression.SelfRenderingExpression) QueryPart(org.hibernate.sql.ast.tree.select.QueryPart) InSubQueryPredicate(org.hibernate.sql.ast.tree.predicate.InSubQueryPredicate)

Aggregations

Expression (org.hibernate.sql.ast.tree.expression.Expression)130 CaseSearchedExpression (org.hibernate.sql.ast.tree.expression.CaseSearchedExpression)68 CaseSimpleExpression (org.hibernate.sql.ast.tree.expression.CaseSimpleExpression)67 BinaryArithmeticExpression (org.hibernate.sql.ast.tree.expression.BinaryArithmeticExpression)62 SqlSelectionExpression (org.hibernate.sql.ast.tree.expression.SqlSelectionExpression)57 ModifiedSubQueryExpression (org.hibernate.sql.ast.tree.expression.ModifiedSubQueryExpression)54 SelfRenderingExpression (org.hibernate.sql.ast.tree.expression.SelfRenderingExpression)54 ColumnReference (org.hibernate.sql.ast.tree.expression.ColumnReference)42 SelfRenderingFunctionSqlAstExpression (org.hibernate.query.sqm.function.SelfRenderingFunctionSqlAstExpression)37 SqlTuple (org.hibernate.sql.ast.tree.expression.SqlTuple)35 SqmExpression (org.hibernate.query.sqm.tree.expression.SqmExpression)34 SelfRenderingSqlFragmentExpression (org.hibernate.sql.ast.tree.expression.SelfRenderingSqlFragmentExpression)33 SelfRenderingAggregateFunctionSqlAstExpression (org.hibernate.query.sqm.function.SelfRenderingAggregateFunctionSqlAstExpression)32 ArrayList (java.util.ArrayList)31 SqmModifiedSubQueryExpression (org.hibernate.query.sqm.tree.expression.SqmModifiedSubQueryExpression)31 TableGroup (org.hibernate.sql.ast.tree.from.TableGroup)28 TableReference (org.hibernate.sql.ast.tree.from.TableReference)25 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)23 ComparisonPredicate (org.hibernate.sql.ast.tree.predicate.ComparisonPredicate)23 NavigablePath (org.hibernate.query.spi.NavigablePath)21