| From a JPQL/HQL perspective, Hibernate will apply the appropriate ON clause for the JOIN based on the entity relationships. I suspect ultimately what you're trying to accomplish would be the following, which works just fine with MySQL:
session.createQuery( "FROM Student s INNER JOIN s.course.teachers AS t WHERE t.name = :name" )
.setParameter( "name", "Alice" )
.getResultList();
You'll notice that rather than using the ON clause to render the predicate, it's applied as a part of the WHERE clause of the outer query, resulting in this SQL:
select
jointest_s0_.id as id1_1_0_,
jointest_t3_.id as id1_2_1_,
jointest_s0_.course_id as course_i3_1_0_,
jointest_s0_.name as name2_1_0_,
jointest_t3_.name as name2_2_1_
from
Student jointest_s0_
inner join
Course jointest_c1_
on jointest_s0_.course_id=jointest_c1_.id
inner join
Teacher_Course teachers2_
on jointest_c1_.id=teachers2_.course_id
inner join
Teacher jointest_t3_
on teachers2_.teacher_id=jointest_t3_.id
where
jointest_t3_.name=?
|