Hi guys. I am a bit stumped on how to do joins using Criteria queries. I am sure its pretty simple but the documentation doesn't seem very clear on this topic.
Say I have the following sql:
Code:
SELECT DISTINCT * FROM permission p
JOIN role_permission rp ON p.permission_id = rp.permission_id
JOIN user_role ur ON rp.role_id = ur.role_id
WHERE ur.user_id = ?;
I am trying to retrieve all the permissions for a given user. To do this I need to join with the role_permission table which is many to many
and join with the user_role table which is also many to many.
I have tried using createAlias and createCriteria but neither are doing what I expect.
If someone can turn this example into a Criteria query, I think I will be able to do anything I need to do.[/code]