CriteriaBuilder: join one-to-many with ON clause
Suppose you the following OneToMany relationships: School->Student->ScientificWork . Now you want to select all Schools that have Student with name 'John' and his scientific job is called 'Black Holes'. I do it like the following, but for some reason it retrurns me all possible schools. public static Specification<School> spec() { return (root, query, cb) -> { final SetJoin<School, Student> studs = root.joinSet("students", JoinType.LEFT); final SetJoin<Student, ScientificWork> works = root.joinSet("works", JoinType.LEFT); return cb.and( cb.equal(studs.get(Student_.name), 'John'), cb.equal