I'm using hibernate 2.1. Say I have three tables:
Person (identifier, name)
Group (identifier, groupname)
GroupMemebership ( person_id, group_id, year)
What I am trying to say is that A person was in a particular group for only a specified year. For example a person might be in an "Undergraduate Student" group in 2004 and a "Graduate Student" in 2005. But both relationships are kept so we can look up what group a person was in for a particular year.
What I want to be able to do is query for a Person object specifying a year, and have it return a person object with it's GroupMembership collection already having a filtered subset based on the year.
Is this possible? I know I can do a filter to get a subset but I'd like to be able to pass a person object with a lazy GroupMembership collection to a View layer and have it load the subset of the GroupMembership collection if the view layer needs it.
|