bonjour,
j'ai un soucis... j'ai trois tables que je dois joindre par une 4 tables créée par hibernate.
tout marche sauf que la table créée n'a que 2 clés primaires(zone_id et role_id) alors que utilisateur_id devrait aussi en etre une... help!
mapping:
Code:
<class name="Role" table="ROLE">
<id name="id" column="ROLE_ID">
<generator class="native"/>
</id>
<property name="nom"/>
<set name="utilisateurs" table="USER_ROLE_ZONE">
<key column="ROLE_ID" not-null="true"/>
<many-to-many column="UTILISATEUR_ID" class="Utilisateur"/>
</set>
<many-to-one name="typeRole"
column="TYPEROLE"
not-null="true"/>
<set name="zones" table="USER_ROLE_ZONE">
<key column="ROLE_ID" not-null="true"/>
<many-to-many column="ZONE_ID" class="Zone"/>
</set>
</class>
<class name="Zone" table="ZONE">
<id name="id" column="ZONE_ID">
<generator class="native"/>
</id>
<discriminator column="type" type="string"/>
<property name="libelle"/>
<property name="actif"/>
<set name="utilisateurs" table="USER_ROLE_ZONE">
<key column="ZONE_ID" not-null="true"/>
<many-to-many column="UTILISATEUR_ID" class="Utilisateur" />
</set>
<set name="roles" table="USER_ROLE_ZONE" inverse="true">
<key column="ZONE_ID" not-null="true"/>
<many-to-many column="ROLE_ID" class="Role"/>
</set>
</class>
<class name="Utilisateur" table="UTILISATEUR">
<id name="id" column="UTILISATEUR_ID">
<generator class="native"/>
</id>
<property name="firstname"/>
<property name="name"/>
<set name="zones"
table="USER_ROLE_ZONE" inverse="true">
<key column="UTILISATEUR_ID" not-null="true"/>
<many-to-many column="ZONE_ID"
unique="true"
class="Zone"/>
</set>
<set name="roles"
table="USER_ROLE_ZONE" inverse="true">
<key column="UTILISATEUR_ID" not-null="true"/>
<many-to-many column="ROLE_ID"
unique="true"
class="Role" />
</set>
</class>