I'd like to add a filtercondition to my criteria query with: cb.and(filtercondition or filterCondition)
so that it's something like:
select * from table t where t.name = 'test' AND (t.place = 'test' OR 'test2');
I've tried the following:
public static Predicate getPredicateForTwoExpressionsAsOrCondition(String filterValue, CriteriaBuilder cb, Expression<String> firstExpression, Expression<String> secondExpression, Predicate filterCondition) {
Predicate or = cb.or(filterCondition, cb.like(cb.lower(secondExpression), "%" + filterValue.toLowerCase() + "%"));
return cb.and(or, cb.like(cb.lower(firstExpression), "%" + filterValue.toLowerCase() + "%"));
}
but now it seems as if he's only taking the firstExpression into account.
note that the above method builds on previous filterConditions.. That's why I'm passing it as a parameter.
Using JPA 2.0 and kind of new with the criteria builder.