-->
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.  [ 3 posts ] 
Author Message
 Post subject: many-to-one problème
PostPosted: Mon Sep 19, 2005 10:19 am 
Newbie

Joined: Fri Sep 02, 2005 10:21 am
Posts: 11
Location: Fribourg, SWITZERLAND
Bonjour à toutes et tous,

J'ai un problème lors d'un mapping avec Hibernate sur une legacy application.

J'ai une table 'FUT_PROJET_RECHERCHE' qui possède un attribut langue 'PR_LNG'. J'ai une table associée qui possède comme clé primaire une composite de 'ET25_NO' et 'ET25_LANGUE'. Cette table contient des langues dans différentes langues (exemple 1, 1,'Français' . 1, 2,'French'. 2,1,'Anglais'. 2,2,'English'.

Au niveau de mes objets j'ai une classe ResearchProject et une classe Language. (Dans ResearchProject j'ai un attribut Language).

J'ai donc besoin d'un mapping <many-to-one>

Code:
<hibernate-mapping package="com.unifr.sis.futura.business">

   <class name="Language" table="PADMINS.ET25_LANGUE"
      lazy="true">

      <composite-id>
         <key-property name="id" column="ET25_NO"></key-property>
         <key-property name="language" column="ET25_LANGUE"></key-property>
      </composite-id>

      <property name="text" column="ET25_NOM2" />

   </class>

</hibernate-mapping>


Code:
<hibernate-mapping package="com.unifr.sis.futura.business">

   <class name="ResearchProject" table="FUT_PROJET_RECHERCHE"
      lazy="true">

      <id name="id" column="PR_NO" type="long" />

      <property name="title" column="PR_TITRE" />
      <property name="summary" column="PR_RESUME" />
      <property name="number" column="PR_NUMERO" />
      <property name="begin" column="PR_DEBUT" />
      <property name="end" column="PR_FIN" />

      <many-to-one name="language" class="Language" lazy="false" update="false" insert="false">
         <column name="PR_LNG" />
         <column name="PR_LNG" />
      </many-to-one>
   </class>

</hibernate-mapping>


Mon problème se situe au niveau <column name="PR_LNG"> que je dois spécifier 2 x (1 fois pour aller chercher la langue et la 2ième fois pour prendre la langue dans la bonne langue)!

Voici l'erreur générée:
org.hibernate.MappingException: Foreign key (FK63C409C2EE8DC94F:FUT_PROJET_RECHERCHE [PR_LNG])) must have same number of columns as the referenced primary key (PADMINS.ET25_LANGUE [ET25_NO,ET25_LANGUE])

Avez vous une idée de comment résoudre ce problème.

Salutations.
Cédric

Hibernate version: 3


Top
 Profile  
 
 Post subject: Re: many-to-one problème
PostPosted: Mon Sep 19, 2005 10:57 am 
Pro
Pro

Joined: Fri Sep 02, 2005 4:21 am
Posts: 206
Location: Vienna
baudet wrote:

Code:
<hibernate-mapping package="com.unifr.sis.futura.business">

...
      <many-to-one name="language" class="Language" lazy="false" update="false" insert="false">
         <column name="PR_LNG" />
         <column name="PR_LNG" />
      </many-to-one>
   </class>

</hibernate-mapping>



Ma proposition - je suis encore en train de tester que ça marche vraiment, mais je ne veux pas faire attendre :-):

Code:
<hibernate-mapping package="com.unifr.sis.futura.business">

...
      <many-to-one name="language" class="Language" lazy="false" update="false" insert="false">
         <column name="PR_LNG" />
         <formula>PR_LNG<formula/>
      </many-to-one>
   </class>

</hibernate-mapping>


Erik


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 20, 2005 2:20 am 
Newbie

Joined: Fri Sep 02, 2005 10:21 am
Posts: 11
Location: Fribourg, SWITZERLAND
Ca fonctionne.
Merci beaucoup.

Cédric


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

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.