当前代码:
CriteriaQuery criteriaQuery = cb.createQuery(MinutisPreke.class);
Root<MinutisPreke> from = criteriaQuery.from(MinutisPreke.class);
Join<LankomumasDiena, MinutisPreke> ld = from.join("lankomumasDiena", JoinType.LEFT);
cb.and(cb.equal(ld.get("intervalas"), 7));
生成以下查询:
SELECT COUNT(t0.pr_id) FROM preke AS t0
LEFT OUTER JOIN lankomumas AS t1
ON (t1.pr_id = t0.pr_id)
WHERE (t1.intervalas = 7)
如何使用条件查询在 LEFT OUTER JOIN ON子句中添加语句,以便我的代码生成此查询:
SELECT COUNT(t0.pr_id) FROM preke AS t0
LEFT OUTER JOIN lankomumas AS t1
ON (t1.pr_id = t0.pr_id) AND (t1.intervalas = 7)
编辑 1: 如果您在第一次和第二次查询中看不到任何区别,请阅读此线程: SQL 连接:where 子句与 on 子句