Hibernate 3.0
MySQL
Hi Folks,
I'm having a horrible time solving a particular N+1 problem and I was hoping somebody here might have some advice.
I have a class (User) that contains within it a set of Responsibilities.
Based upon various security requirements, not every User caa see every single one of his responsibilities. Thus User "Bob" might have responsibilities A, B, C but under his security context he's only supposed to see A and C.
I want to display a list of Users and have one of the columns be the set of (filtered) responsibilities.
Right now, I'm querying the Users (step 1), and then doing a subselect with a Filter to get the responsibilities for each row. A classic N+1 approach.
Can anyone suggest a way to eagerly fetch the responsibilities that would include the filter criteria?
|