I\'m trying to do a basic \"OR\" on three fields using a hibernate criteria query.
Example
class Whatever{
string name;
string address;
string pho
This is what worked for me for an OR condition, that too with an IN condition and not the answer up-voted most on this discussion:
criteria.add( Restrictions.or(
Restrictions.eq(ch.getPath(ch.propertyResolver().getXXXX()), "OR_STRING"),
Restrictions.in(ch.getPath(ch.propertyResolver().getYYYY()), new String[]{"AA","BB","CC"})
));
Resulting Query:
and (
this_.XXXX=?
or this_.YYYY in (
?, ?, ?
)
)