annotations - Hibernate Many to Many on many to -


I am trying to map an existing database for hibernate using annotations. The problem is as follows.

There are many relationships in 'Organization' and 'Organization_roll' which are resolved in the 'Organization_Hess_Roll' in the table, in which the two primary keys are used as the primary primary key in the table joining .

The next is a 'User' table. Users can have a role in many organizations, it has been resolved in an included table named 'users_has_organizations_and_role' which contains' user_id ',' organization_id 'and' Organization_role_id 'has the primary primary key and a unique_index on' user_id 'and' organization_id '.

'users_has_organizations_and_role' 'organization_has_roles' refers to the entire primary key (organization_id, organization_role_id) and the user table (user_id)

I can not find an example on this matter .

Is it possible to map it?

I am using Hibernation 4, though it does not matter ..

organization_has_roles ) which is translated into Oo as a relationship. Since this relationship is not a unit, and it does not have any @ id , it can not be referenced in any other entity.

A solution is to map database SPT organization_has_roles to a JPA / Hibernate unit, either with a composite key or with a synthetic key (whatever you like We do). You can then refer to this unit in your user model.

Comments