Closed dotWee closed 8 years ago
Does Criterion.or
meet your needs?
Criterion orConcatenatedCriterion = Criterion.or(criterion1, criterion2, ..., criterionN);
query.where(orConcatenatedCriterion);
Yes! That was quick. Thanks for the fast answer!
Great! Glad that worked, I wasn't sure if the varargs would be a feasible approach for you or if it HAD to be a List :) If you had needed to iterate through the list, you can also do the following:
Criterion orCriterion = criterionList.get(0);
for (int i = 1; i < criterionList.size(); i++) {
orCriterion = orCriterion.or(criterionList.get(i));
}
query.where(orCriterion);
I think creating a conjunction criterion like this from a List rather than the varargs array Criterion.or and Criterion.and is a valid use case, so we can introduce functions to make this easier in a future release. Glad that the varargs version works for you though!
I'm looking for a way to apply multiple criterions (from a List) to a single query, seperated by the 'OR' operator.
I tried this using the Query.fork() function and appending another criterion in a for-loop. But those criterions get seperated using the operator 'AND'.
Is there any simple way to achieve this, except compiling every query and appending them to plain SQL?