Search in sources :

Example 1 with BetweenPredicate

use of org.hibernate.sql.ast.tree.predicate.BetweenPredicate 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 2 with BetweenPredicate

use of org.hibernate.sql.ast.tree.predicate.BetweenPredicate in project hibernate-orm by hibernate.

the class BaseSqmToSqlAstConverter method visitBetweenPredicate.

@Override
public BetweenPredicate visitBetweenPredicate(SqmBetweenPredicate predicate) {
    final FromClauseIndex fromClauseIndex = fromClauseIndexStack.getCurrent();
    final Expression expression;
    final Expression lowerBound;
    final Expression upperBound;
    inferrableTypeAccessStack.push(() -> coalesceSuppliedValues(() -> determineValueMapping(predicate.getLowerBound(), fromClauseIndex), () -> determineValueMapping(predicate.getUpperBound(), fromClauseIndex)));
    try {
        expression = (Expression) predicate.getExpression().accept(this);
    } finally {
        inferrableTypeAccessStack.pop();
    }
    inferrableTypeAccessStack.push(() -> coalesceSuppliedValues(() -> determineValueMapping(predicate.getExpression(), fromClauseIndex), () -> determineValueMapping(predicate.getUpperBound(), fromClauseIndex)));
    try {
        lowerBound = (Expression) predicate.getLowerBound().accept(this);
    } finally {
        inferrableTypeAccessStack.pop();
    }
    inferrableTypeAccessStack.push(() -> coalesceSuppliedValues(() -> determineValueMapping(predicate.getExpression(), fromClauseIndex), () -> determineValueMapping(predicate.getLowerBound(), fromClauseIndex)));
    try {
        upperBound = (Expression) predicate.getUpperBound().accept(this);
    } finally {
        inferrableTypeAccessStack.pop();
    }
    return new BetweenPredicate(expression, lowerBound, upperBound, predicate.isNegated(), getBooleanType());
}
Also used : BetweenPredicate(org.hibernate.sql.ast.tree.predicate.BetweenPredicate) SqmBetweenPredicate(org.hibernate.query.sqm.tree.predicate.SqmBetweenPredicate) BinaryArithmeticExpression(org.hibernate.sql.ast.tree.expression.BinaryArithmeticExpression) SqmModifiedSubQueryExpression(org.hibernate.query.sqm.tree.expression.SqmModifiedSubQueryExpression) SelfRenderingFunctionSqlAstExpression(org.hibernate.query.sqm.function.SelfRenderingFunctionSqlAstExpression) SelfRenderingAggregateFunctionSqlAstExpression(org.hibernate.query.sqm.function.SelfRenderingAggregateFunctionSqlAstExpression) CaseSearchedExpression(org.hibernate.sql.ast.tree.expression.CaseSearchedExpression) SelfRenderingSqlFragmentExpression(org.hibernate.sql.ast.tree.expression.SelfRenderingSqlFragmentExpression) Expression(org.hibernate.sql.ast.tree.expression.Expression) SelfRenderingExpression(org.hibernate.sql.ast.tree.expression.SelfRenderingExpression) SqmExpression(org.hibernate.query.sqm.tree.expression.SqmExpression) CaseSimpleExpression(org.hibernate.sql.ast.tree.expression.CaseSimpleExpression) SqlSelectionExpression(org.hibernate.sql.ast.tree.expression.SqlSelectionExpression) ModifiedSubQueryExpression(org.hibernate.sql.ast.tree.expression.ModifiedSubQueryExpression)

Aggregations

BinaryArithmeticExpression (org.hibernate.sql.ast.tree.expression.BinaryArithmeticExpression)2 CaseSearchedExpression (org.hibernate.sql.ast.tree.expression.CaseSearchedExpression)2 CaseSimpleExpression (org.hibernate.sql.ast.tree.expression.CaseSimpleExpression)2 Expression (org.hibernate.sql.ast.tree.expression.Expression)2 ModifiedSubQueryExpression (org.hibernate.sql.ast.tree.expression.ModifiedSubQueryExpression)2 SelfRenderingExpression (org.hibernate.sql.ast.tree.expression.SelfRenderingExpression)2 SqlSelectionExpression (org.hibernate.sql.ast.tree.expression.SqlSelectionExpression)2 BetweenPredicate (org.hibernate.sql.ast.tree.predicate.BetweenPredicate)2 SelfRenderingAggregateFunctionSqlAstExpression (org.hibernate.query.sqm.function.SelfRenderingAggregateFunctionSqlAstExpression)1 SelfRenderingFunctionSqlAstExpression (org.hibernate.query.sqm.function.SelfRenderingFunctionSqlAstExpression)1 SqmExpression (org.hibernate.query.sqm.tree.expression.SqmExpression)1 SqmModifiedSubQueryExpression (org.hibernate.query.sqm.tree.expression.SqmModifiedSubQueryExpression)1 SqmBetweenPredicate (org.hibernate.query.sqm.tree.predicate.SqmBetweenPredicate)1 SelfRenderingSqlFragmentExpression (org.hibernate.sql.ast.tree.expression.SelfRenderingSqlFragmentExpression)1