These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: probleme 3 clés primaires
PostPosted: Tue Feb 13, 2007 10:55 am 
Newbie

Joined: Tue Feb 13, 2007 10:51 am
Posts: 3
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>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.