From the Hibernate 3.6 documentation:
You can provide additional join conditions using the HQL keyword with the keyword.
from Cat as cat left join cat.kittens as kitten with kitten.bodyWeight > 10.0
This with clause allows you to add a constraint on the JOIN clause (ON clause). Is there such a thing in JPQL?
When I run the following JPQL:
select c from ContainerDef c left join fetch c.displayState ds where c.id = 1 and ds.user.id = 2
The following SQL is created:
select ... from CONTAINER_DEF containerd0_ left outer join USER_CONTAINERDEF displaysta1_ on containerd0_.CONTAINERDEF_ID=displaysta1_.CONTAINERDEF_ID where containerd0_.CONTAINERDEF_ID=? and displaysta1_.AUTHUSER_ID=?
What really needs to happen is:
select ... from CONTAINER_DEF containerd0_ left outer join USER_CONTAINERDEF displaysta1_ on containerd0_.CONTAINERDEF_ID=displaysta1_.CONTAINERDEF_ID and displaysta1_.AUTHUSER_ID=? where containerd0_.CONTAINERDEF_ID=?
I am sure that I am missing the correct JPQL clause for HQL with .
source share