-->
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: utilisation relation one-to-one avec une composite key
PostPosted: Fri Jul 08, 2005 8:47 am 
Newbie

Joined: Fri Jul 08, 2005 8:30 am
Posts: 1
Bonjour,

je suis en version 2.1.6 d'hibernate.
Mon souci est que j'ai une relation 1-1 entre 2 tables qui ont toutes les deux une composite key ().

Lot: idlot
1-n
Msg: idlot, idmsg
1-1
MsgAssocie: idlot, idmsg

et je ne sais pas comment specifier cela dans mes mappings afin que lorsque j'ajoute un MsgAssocié a mon Msg, il renseigne automatiquement les clés composés.
Avec une clé simple je vois bien comment faire mais en composé j'ai pas trouvé.

mes mappings sont:

<class name="Lot" table="Lot">
<id
name="id"
type="java.lang.Long"
column="ID"
>
<generator class="sequence">
<param name="sequence">seqtoto</param>
</generator>
</id>
<set
name="msg"
lazy="true"
inverse="true"
cascade="save-update"
>
<key>
<column name="IDLOT" />
</key>
<one-to-many
class="Msg"
/>
</set>

</class>

<class
name="Msg"
table="Msg"
>
<composite-id unsaved-value="any">
<key-many-to-one
name="lot"
class="Lot"
column="IDLOT"
/>
<key-property
name="idmsg"
column="IDMSG"
type="java.lang.Long"
length="10"
>
</key-property>
</composite-id>


<one-to-one
name="msgAssocie"
class="MsgAssocie"
outer-join="auto"
cascade="save-update"
>
</one-to-one>
</class>

<class
name="MsgAssocie"
table="MsgAssocie"
>
<composite-id unsaved-value="any">
<key-property
name="idlot"
column="IDLOT"
type="java.lang.Long"
length="10"
>
</key-property>
<key-property
name="idmsg"
column="IDMSG"
type="java.lang.Long"
length="10"
>
</key-property>
</composite-id>
<one-to-one
name="msg"
class="Msg"
outer-join="auto"
constrained="true"
>
</one-to-one>
</class>

quand je sauve mon objet, il me dit:
net.sf.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: MsgAssocie@4d2af2[idlot=<null>,idmsg=<null>], of class: MsgAssocie. Il ne renseigne pas les clés de mon objet MsgAssocié en fonction de Msg


est ce que quelqu'un saurait me renseigner. Merci d'avance.



Aurel.


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.