I need to restrict the resulting rows from each table/object depending on my security rules per logged user.
I thought to use implement PreLoadEventListener
.
Regarding performance - how expensive is it to use onPreLoad for each entity? does Hibernate assign the relevant listener via Reflection? Is it done once per Hibernate session or each find will it invoke the reflection to find the appropiate listener?
EDITED
The security condition is complicated. It's based on 5 tables, since I have to check the user group to check that one of the group's role has access to the row in the database (labeling security). It's a condition on a field value in one table.