Hibernate Criteria Restrictions AND / OR combination
我将如何使用Hibernate限制来实现这一点?
(((A='X') and (B in('X',Y))) or ((A='Y') and (B='Z')))
认为有用
Criteria criteria = getSession().createCriteria(clazz);
Criterion rest1= Restrictions.and(Restrictions.eq(A, "X"),
Restrictions.in("B", Arrays.asList("X",Y)));
Criterion rest2= Restrictions.and(Restrictions.eq(A, "Y"),
Restrictions.eq(B, "Z"));
criteria.add(Restrictions.or(rest1, rest2));
链接地址: http://www.djcxy.com/p/37116.html
上一篇: Hibernate对Criteria API进行子选择:MySql中的性能下降
下一篇: 休眠标准限制和/或组合