Search in sources :

Example 1 with PredicateBinaryOp

use of io.micronaut.data.model.jpa.criteria.impl.predicate.PredicateBinaryOp in project micronaut-data by micronaut-projects.

the class QueryModelPredicateVisitor method visit.

@Override
public void visit(PersistentPropertyBinaryPredicate<?> propertyToExpressionOp) {
    PersistentPropertyPath<?> propertyPath = propertyToExpressionOp.getPropertyPath();
    PredicateBinaryOp op = propertyToExpressionOp.getOp();
    Expression<?> expression = propertyToExpressionOp.getExpression();
    visitPropertyPathPredicate(propertyPath, expression, op);
}
Also used : PredicateBinaryOp(io.micronaut.data.model.jpa.criteria.impl.predicate.PredicateBinaryOp)

Example 2 with PredicateBinaryOp

use of io.micronaut.data.model.jpa.criteria.impl.predicate.PredicateBinaryOp in project micronaut-data by micronaut-projects.

the class QueryModelPredicateVisitor method visit.

@Override
public void visit(ExpressionBinaryPredicate expressionBinaryPredicate) {
    Expression<?> left = expressionBinaryPredicate.getLeft();
    PredicateBinaryOp op = expressionBinaryPredicate.getOp();
    if (left instanceof PersistentPropertyPath) {
        visitPropertyPathPredicate((PersistentPropertyPath<?>) left, expressionBinaryPredicate.getRight(), op);
    } else if (left instanceof IdExpression) {
        if (op == PredicateBinaryOp.EQUALS) {
            add(Restrictions.idEq(asValue(expressionBinaryPredicate.getRight())));
        } else {
            throw new IllegalStateException("Unsupported ID expression OP: " + op);
        }
    } else {
        throw new IllegalStateException("Unsupported expression: " + left);
    }
}
Also used : PredicateBinaryOp(io.micronaut.data.model.jpa.criteria.impl.predicate.PredicateBinaryOp) IdExpression(io.micronaut.data.model.jpa.criteria.impl.IdExpression) PersistentPropertyPath(io.micronaut.data.model.jpa.criteria.PersistentPropertyPath)

Aggregations

PredicateBinaryOp (io.micronaut.data.model.jpa.criteria.impl.predicate.PredicateBinaryOp)2 PersistentPropertyPath (io.micronaut.data.model.jpa.criteria.PersistentPropertyPath)1 IdExpression (io.micronaut.data.model.jpa.criteria.impl.IdExpression)1