I'd like to make a criteria query with 3 OR Criterions and I dont know what is the best way to do it.
Currently I only have 2 or Restrictions.
Criteria crit = session.createCriteria(Reader.class)
.add(Restrictions.or(Restrictions.like(PUBLICATION_ID_FIELD, "Question",MatchMode.END), Restrictions.like(PUBLICATION_ID_FIELD, "Idea",MatchMode.END)));
How can I add a third one ?
You can either "or" one more restriction to the result:
Criteria criteria = session.createCriteria(Reader.class);
criteria.add(Restrictions.or(Restrictions.or(condition1, condition2), condition3));
or use Disjunction:
Criteria criteria = session.createCriteria(Reader.class);
Junction conditionGroup = Restrictions.disjunction();
conditionGroup.add(condition1).add(condition2).add(condition3);
criteria.add(conditionGroup);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With