I have 3 main tables: USER, GROUP, ROLE
USER and GROUP many-to-many relationship is implemented via GROUP_USER table and GroupUser class.
GROUP and ROLE many-to-many relationship is implemented via GROUP_ROLE table and GroupRole class.
Now, for a given group, a user plays a particular role. So I then have another table called GROUP_USER_ROLE which has two complex foreign keys, one maps the GROUP_ID and USER_ID to those in the GROUP_USER table and the other maps the GROUP_ID and ROLE_ID to those in the GROUP_ROLE table.
How do I model such a relationship in hibernate? Please give an example, if possible.
|