With
HHH-16 Closed we can join classes that don't have any assosiation. Anyway, if the joined class further joins its assosiations, the join clause is missing in the generated SQL. For example this HQL:
select c.id, o.id, i.id
from Customer c
left join Order o on c.id = o.customer.id
left join o.items i
generates SQL like this:
select
customer0_.id as col_0_0_,
order1_.id as col_1_0_,
items2_.id as col_2_0_
from
TEST_CUSTOMER customer0_
left outer join
TEST_ORDER order1_
on (
customer0_.id=order1_.customer
)
Order is joined, OrderItem is not. Note that the item id column alias is there. Implicit join doesn't work as well (see
HHH-10503 Open ). Workaround: If the second join used ON clause, it works fine. This most probably applies for subsequent joins as well, thus, once the ON clause is used, we cannot go back to joining assosiations. HQL that works:
select c.id, o.id, i.id
from Customer c
left join Order o on c.id = o.customer.id
left join OrderItem i on i.order.id = o.id
I am attaching few tests to check the behaviour. If I knew where to start, I might try to create a patch as well. |