hibernate restrictions and/or order

criteria, hibernate, java

Solution

It should be treated as the latter

(((A and B) or C) and D)

You could do

criterion = Restriction.or(Restrictions.and(criterionA, criterionB), Restrictions.and(criterionC, criterionD))

If you want the first solution

Problem

small questions about Restrictions.or and Restrictions.and If I do something like this: ``` ... criterion = criterionA; criterion = Restrictions.and(criterion, criterionB); criterion = Restrictions.or(criterion, criterionC); criterion = Restrictions.and(criterion, criterionD); ``` Will this be treated as: ``` (A and B) or (C and D) (following mathematical conventions) ``` Or will it be treated in the order it the restrictions have been added: ``` (((A and B) or C) and D) ``` Please also add references if there are any...

Original source