The current code:
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));
generates the following query:
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)
How to add statement in the LEFT OUTER JOIN ON clause using criteria query so my code would generate this query:
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)
EDIT 1: If you don't see any difference in first and second querys, please read this thread: SQL join: where clause vs. on clause