This content has been marked as final.
Show 1 reply
-
1. Re: How to write join in HQL
asookazian Jul 1, 2009 10:33 PM (in response to bryan_1983)http://docs.jboss.org/hibernate/stable/core/reference/en/html/queryhql.html#queryhql-joins
from Cat as cat inner join cat.mate as mate
the getMate() method will be called to return 1 (or many?) mates for the cats.
I don't like these goofy Cat examples in the HQL docs.
It's easier to think about this with a real-world example like Customer and Order entities.
So imagine there is a 1:m relationship between Customer and Order entities. The following query returns all Order entities that have 'Johnson' as the customer's last name.
select o from Order o inner join o.customer c where c.lastName = 'Johnson'
Read JPA/Hibernate book for more info.