Hello all, I hope that this question doesn't get asked too often (I've put a to the point question at the end of the post).
Unfortunately I couldn't find much on google, but maybe I don't know the technical name for exactly what I'm trying to do. (So if someone could even tell me that, I could google more!)
Hibernate version:
3.2.5.ga
Tables
Code:
Users
Id
Username
Projects
Id
Code
Description
ProjectAssignments
Id
UserId
ProjectId
ProjectRoleId
ProjectRoles
Id
RoleName
Background:
A user can be assigned to projects via the ProjectAssignments table.
There are multiple roles, such as "Supervisor", "Reviewer".
One user can be assigned to many different projects as the same role, i.e, they can supervise many projects.
Furthermore, each project can have many users assigned to it, i.e, the project will have supervisors and reviewers.
Question:
Essentially I want to be able to do a Users.getSupervisedProjects();
I therefore need an underlaying collection that is mapped
RoleName => Project.
This is well and simple with a <map> as I can use the <map key column="ProjectRoleId">, however as a map could only map one Supervisor => Project association, it is no good (as a user may have may Supervisor roles).
I therefore need to use a <bag>, but the documentation says that a <bag> can't set up a key like the Map does.
Then there is IDBag, but the documentation says that the index generator may not pull info from the table like the <map key> can.
To the point question
Am I forced essentially to hold a set of ProjectAssignment classes in a set, instead of making the ProjectRoleId an index on my collection.
Thank you very much for reading, and thanks in advance for any replies.