本文介绍了休眠标准限制和/或组合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
(((A ='X')and(B in(B) '')或((A ='Y')和(B ='Z')))
解决方案 think works
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));
How would I achieve this using Hibernate Restrictions?
(((A='X') and (B in('X',Y))) or ((A='Y') and (B='Z')))
解决方案 think works
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));
这篇关于休眠标准限制和/或组合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!