I need to achieve a query like this below.
select * from example where ( a ) or ( b or c or d)
Here a,b,c,d are expressions.
Criteria criteria = session.createCriteria(Example.class); criteria.add(Restrictions.sqlRestriction("where (a)"));
This is the criteria what i get, which i can't change. (b or c or d) this can achieved using disjunction.
Disjunction disjunction = Restrictions.disjunction(); disjunction.add(b).add(c).add(d).
But if i add this disjunction to the criteria , it adds AND. i,e select * from example where ( a ) and ( b or c or d). which is not my requirement criteria.add(disjunction);
Could you please help me on how to add disjunction to sql restriciton with OR condition?
|