In my system I have the following classes:
Files belong to one or more categories
Users can have one or more roles
A permission can refer to a file or a category of files (never both)
A permission can refer to a user or role (and so affecting all users in that role) (never both user and role)
Permission has 3 booleans, read, write, edit
I need a HQL query to get all files accessible by a user. It should return all files that have a read permission for that user or any of the roles assigned to the user and all files belonging to a category that has a read permission to that user or any of the roles assigned to the user.
I am pretty new to Hibernate/JBoss and I've been examining example queries but can't find anyone similar to this one... any directions/help?