disjunction().add()的参数是Criterion 而我在add里面还想加条件 想再加个conjunction 请问怎么写呢?
[b]问题补充:[/b]
就是实现一个 where a=a1 or b=b1 or ((c=c1 and d=d1) or (d=d1 and e=e2)or ...) 请问用QBC怎么写?
我喜欢分开写,一行一行看得清楚。
[code="java"]
DetachedCriteria dc = DetachedCriteria.forClass(clazz);
Junction and01 = Restrictions.conjunction();
and01.add(Restrictions.eq("c", 'c1'));
and01.add(Restrictions.eq("d", 'd1'));
Junction and02 = Restrictions.conjunction();
and02.add(Restrictions.eq("d", 'd1'));
and02.add(Restrictions.eq("e", 'e2'));
Junction or02 = Restrictions.disjunction().add(and01).add(and02);
Junction or01 = Restrictions.disjunction();
or01.add(Restrictions.eq("a", 'a1'));
or01.add(Restrictions.eq("b", 'b1'));
or01.add(or02);
dc.add(or01);
[/code]
disjunction?能不能写清楚一点 :(
用Restrictions.or应该能实现!