关于Restrictions.or和Restrictions.and的小问题
如果我做这样的事情:
...
criterion = criterionA;
criterion = Restrictions.and(criterion, criterionB);
criterion = Restrictions.or(criterion, criterionC);
criterion = Restrictions.and(criterion, criterionD);
这会被视为:
(A and B) or (C and D) (following mathematical conventions)
或者它将按照添加限制的顺序进行处理:
(((A and B) or C) and D)
如果有的话还请添加参考文献…
解决方法:
它应该被视为后者
(((A and B) or C) and D)
你可以做到
criterion = Restriction.or(Restrictions.and(criterionA, criterionB), Restrictions.and(criterionC, criterionD))
如果你想要第一个解决方案