I'm migrating from Castor to Hibernate and have a question about how to navigate many-to-many-to-many relations in HQL.
The datastructure of my application is like this:
Item -- Collection -- Acl -- Role -- User
(all relations are many-to-many).
Now, in Castor I could write something like:
SELECT i FROM Item i WHERE i.id = $1 AND i.collection.acl.role.user.username = $2
in order to retrieve all items that a particular user has access to.
When I try something similar with Hibernate I get this error message:
net.sf.hibernate.QueryException: expecting 'elements' or 'indices' after: acl
Here is the Hibernate query that fails:
select i from Item as i where i.id = ? and i.collection.acl.role.user.id = ?
Is it possible to navigate through more than one many-to-many relation in Hibernate? If so, how? The database I use is MySQL 4.0.
Thanks
Per Thomas
|