Search in sources :

Example 1 with InPredicate

use of com.blazebit.persistence.parser.predicate.InPredicate in project blaze-persistence by Blazebit.

the class GeneralParserTest method testInParameterNoParenthesis.

@Test
public void testInParameterNoParenthesis() {
    GeneralCaseExpression result = (GeneralCaseExpression) parse("CASE WHEN a.x IN :abc THEN 0 ELSE 1 END");
    GeneralCaseExpression expected = new GeneralCaseExpression(Arrays.asList(new WhenClauseExpression(new InPredicate(path("a", "x"), new ParameterExpression("abc", null, true)), _int("0"))), _int("1"));
    assertEquals(expected, result);
}
Also used : InPredicate(com.blazebit.persistence.parser.predicate.InPredicate) Test(org.junit.Test)

Example 2 with InPredicate

use of com.blazebit.persistence.parser.predicate.InPredicate in project blaze-persistence by Blazebit.

the class GeneralParserTest method testInNumericLiterals.

@Test
public void testInNumericLiterals() {
    GeneralCaseExpression result = (GeneralCaseExpression) parse("CASE WHEN a.x IN (1, 2, 3, 4) THEN 0 ELSE 1 END");
    GeneralCaseExpression expected = new GeneralCaseExpression(Arrays.asList(new WhenClauseExpression(new InPredicate(path("a", "x"), _int("1"), _int("2"), _int("3"), _int("4")), _int("0"))), _int("1"));
    assertEquals(expected, result);
}
Also used : InPredicate(com.blazebit.persistence.parser.predicate.InPredicate) Test(org.junit.Test)

Example 3 with InPredicate

use of com.blazebit.persistence.parser.predicate.InPredicate in project blaze-persistence by Blazebit.

the class GeneralParserTest method testInCharacterLiterals.

@Test
public void testInCharacterLiterals() {
    GeneralCaseExpression result = (GeneralCaseExpression) parse("CASE WHEN a.x IN ('1', '2', '3', '4') THEN 0 ELSE 1 END");
    GeneralCaseExpression expected = new GeneralCaseExpression(Arrays.asList(new WhenClauseExpression(new InPredicate(path("a", "x"), _string("1"), _string("2"), _string("3"), _string("4")), _int("0"))), _int("1"));
    assertEquals(expected, result);
}
Also used : InPredicate(com.blazebit.persistence.parser.predicate.InPredicate) Test(org.junit.Test)

Example 4 with InPredicate

use of com.blazebit.persistence.parser.predicate.InPredicate in project blaze-persistence by Blazebit.

the class RestrictionBuilderImpl method notInCollectionExpression.

@Override
public T notInCollectionExpression(String collectionParameterExpression) {
    if (collectionParameterExpression == null) {
        throw new NullPointerException("collectionParameterExpression");
    }
    ParameterExpression collectionParameter = (ParameterExpression) expressionFactory.createInItemExpression(collectionParameterExpression);
    collectionParameter.setCollectionValued(true);
    return chain(new InPredicate(true, leftExpression, collectionParameter));
}
Also used : ParameterExpression(com.blazebit.persistence.parser.expression.ParameterExpression) InPredicate(com.blazebit.persistence.parser.predicate.InPredicate)

Example 5 with InPredicate

use of com.blazebit.persistence.parser.predicate.InPredicate in project blaze-persistence by Blazebit.

the class RestrictionBuilderImpl method in.

private SubqueryBuilder<T> in(String subqueryAlias, String expression, boolean negated, FullQueryBuilder<?, ?> criteriaBuilder) {
    verifyBuilderEnded();
    this.predicate = new InPredicate(negated, leftExpression);
    Expression superExpression = expressionFactory.createSimpleExpression(expression);
    rightSuperExprSubqueryBuilderListener = new SuperExpressionSubqueryBuilderListener<T>(subqueryAlias, superExpression) {

        @Override
        public void onBuilderEnded(SubqueryInternalBuilder<T> builder) {
            super.onBuilderEnded(builder);
            onSubqueryBuilderEnded(superExpression);
            listener.onBuilderEnded(RestrictionBuilderImpl.this);
        }
    };
    return subqueryInitFactory.createSubqueryBuilder(result, rightSuperExprSubqueryBuilderListener, false, criteriaBuilder, clause);
}
Also used : Expression(com.blazebit.persistence.parser.expression.Expression) ParameterExpression(com.blazebit.persistence.parser.expression.ParameterExpression) PathExpression(com.blazebit.persistence.parser.expression.PathExpression) SubqueryExpression(com.blazebit.persistence.parser.expression.SubqueryExpression) InPredicate(com.blazebit.persistence.parser.predicate.InPredicate)

Aggregations

InPredicate (com.blazebit.persistence.parser.predicate.InPredicate)19 ParameterExpression (com.blazebit.persistence.parser.expression.ParameterExpression)8 Expression (com.blazebit.persistence.parser.expression.Expression)7 PathExpression (com.blazebit.persistence.parser.expression.PathExpression)7 SubqueryExpression (com.blazebit.persistence.parser.expression.SubqueryExpression)7 Test (org.junit.Test)5 FunctionExpression (com.blazebit.persistence.parser.expression.FunctionExpression)2 MultipleSubqueryInitiatorImpl (com.blazebit.persistence.impl.MultipleSubqueryInitiatorImpl)1 ExpressionBuilder (com.blazebit.persistence.impl.builder.expression.ExpressionBuilder)1 ExpressionBuilderEndedListener (com.blazebit.persistence.impl.builder.expression.ExpressionBuilderEndedListener)1 ArithmeticExpression (com.blazebit.persistence.parser.expression.ArithmeticExpression)1 ArrayExpression (com.blazebit.persistence.parser.expression.ArrayExpression)1 GeneralCaseExpression (com.blazebit.persistence.parser.expression.GeneralCaseExpression)1 ListIndexExpression (com.blazebit.persistence.parser.expression.ListIndexExpression)1 MapEntryExpression (com.blazebit.persistence.parser.expression.MapEntryExpression)1 MapKeyExpression (com.blazebit.persistence.parser.expression.MapKeyExpression)1 MapValueExpression (com.blazebit.persistence.parser.expression.MapValueExpression)1 NullExpression (com.blazebit.persistence.parser.expression.NullExpression)1 NumericLiteral (com.blazebit.persistence.parser.expression.NumericLiteral)1 PathElementExpression (com.blazebit.persistence.parser.expression.PathElementExpression)1