OK, with a little experimenting, the 1st case can be done as
SELECT e.FullName, p.PhoneNumber
FROM Employee AS e
LEFT JOIN e.Phones AS p
WHERE p.IsPrimary = true
It's a little odd that you join to the collection when you really mean one of its members, but it works. Too bad you can't leave out the verbose JOIN and just do
SELECT e.FullName, e.Phones.PhoneNumber ...
I still have no idea how to do the 2nd case. Can someone point me to examples of using HQL's "collection expressions", i.e.
{ some, exists, all, any }
I picked up the book Pro Hibernate 3, which mentions them, but no details or examples are given :(
|