-->
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: HowTo:table references itself in a many-to-many association?
PostPosted: Mon Jul 12, 2004 12:25 pm 
Newbie

Joined: Thu Jun 10, 2004 5:37 am
Posts: 19
I have some problem when I use the tag <set ...>

I've done something like this :

<!-- TABLE DEC_COMPOSANTE_BATIMENT -->
<class name="HbDecComposanteBatiment"
table="DEC_COMPOSANTE_BATIMENT">

<id name="id" column="ID_COMPOSANTE_BATIMENT" type="java.lang.Long">
.....


<set name="composantesBatimentAvApr" table="DEC_LIEN_COMPO_BATIMENT_AV_APR"
lazy="true" cascade="none">
<key>
<column name="ID_COMPOSANTE_BATIMENT" not-null="true"/>
</key>
<many-to-many class="HbDecComposanteBatiment">
<column name="ID_COMPOSANTE_BATIMENT" not-null="true"/>
</many-to-many>
</set>

--> I obtain the following error :

"Repeated column in mapping for collection: vdm.administration.referentiel.dao.hbbean.HbDecComposanteBatiment.composantesBatimentAvApr column: ID_COMPOSANTE_BATIMENT"


As you can see I have twice the column ID_COMPOSANTE_BATIMENT in the tag <set> because I made a many-to-many association on the same table (HbDecComposanteBatiment references itsef in a many-to-many association).

How can I avoid this problem ?

Thanks for your help,

Nicolas
[/b]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 12, 2004 12:44 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Hi,
Try this one
Code:
<set name="composantesBatimentAvApr" table="DEC_LIEN_COMPO_BATIMENT_AV_APR"
lazy="true" cascade="none">
<key>
<column name="ID_COMPOSANTE_BATIMENT_AV" not-null="true"/>
</key>
<many-to-many class="HbDecComposanteBatiment">
<column name="ID_COMPOSANTE_BATIMENT_APR" not-null="true"/>
</many-to-many>
</set>


The avant id should be distinct from thez apr

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Thank you
PostPosted: Tue Jul 13, 2004 3:58 am 
Newbie

Joined: Thu Jun 10, 2004 5:37 am
Posts: 19
Ok thank you, I thought I was obliged to use the id's names specified in my relationnal database in the mapping file.

But it seems I'm not obliged, thus you're right.


Thanks


Nicolas


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.