代码
Predicate exp1 = cb.and(cb.equal(root.get("day"), "2018-01-02"), cb.equal(root.get("frequency"), 200));
Predicate exp2 = cb.and(cb.equal(root.get("day"), "2018-01-01"), cb.notEqual(root.get("frequency"), 100));
Predicate p2 = cb.or(exp1,exp2);
代码生成的 sql 是:
select * from stat_report report0_ where (report0_.day=? and report0_.frequency=? or report0_.day=? and report0_.frequency<>?);
我想生成的 sql 是:
select * from stat_report report0_ where ((report0_.day=? and report0_.frequency=? ) or (report0_.day=? and report0_.frequency<>?));
有大神指导下没 😄
1
abcdxx OP ?
|
2
airfling 2018-06-10 18:50:59 +08:00 via Android
jpa 不是可以直接加注解写自定义的 sql 吗
|
3
sagaxu 2018-06-11 09:47:28 +08:00 via Android
|
4
ukipoi 2018-06-14 08:41:50 +08:00
感觉 A&B or C&D 和 (A&B) or (C&D)一样
|