I have a table of data, and another table that defines which users have permissions to see the rows in the table. Basically what I want is for the events, if no permissions are setup it returns to all users. If it has any permissions setup, it should check the user's permission list against the permission resources in the IncludedResource table...
Table Event
-------------------
id | .....
Table Included resource (used for security access)
------------------------------------------------------------------------
toObject (points to event) | fromResource (points to permission)
I have the following HQL query:
Code:
SELECT event FROM d131.calendar.event.Event as event left outer join event.includedResources includedresource where event.id != includedresource.toObject or (event.id = includedresource.toObject and event.id = includedresource.toObject and includedresource.fromResource in (?, ?)
I want it to look like the SQL:
Code:
SELECT events.* FROM events right outer JOIN includedresource on events.id where events.id != includedresource.objectid or events.id = includedresource.objectid and includedresource.resourceId in (98, 102)
Basically the main difference is after the join in the on clause, the HCL automatically make the on clause be the id links (
Code:
includedResouce.objectId = event.id
) and for me to get the results I want, I must have simply
Code:
event.id
Any ideas? It works well for checking to see that users can only see events they have permission to see, but it will not return events with no permission setup!
Thanks
Tony