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: 3rd column in a many-to-many relationship
PostPosted: Thu Jan 04, 2007 9:52 am 
Newbie

Joined: Mon Aug 09, 2004 2:50 pm
Posts: 10
Location: Sao Paulo , SP, Brazil
Hi,

I´m using Hibernate 3.2 and I´d like to know how I can to declare a 3rd column in a relationship table, like this:

Class Person:
attributes id, name

Class Scholl:
attributes id, name

If I make a many-to-many between this classes:

Person.hbm.xml:
...
<set
name="scholls"
table="Person_Scholl"
lazy="true"
cascade="none"
sort="unsorted"
>

<key
column="ID_PERSON"
>
</key>

<many-to-many
class="myPackage.Scholl"
column="ID_SCHOLL"
outer-join="auto"
/>

</set>

If I make this mapping, the relationship table Person_Scholl must have two columns: ID_PERSON and ID_SCHOLL.

How can I put a 3rd column in this table (a INFORMATION column) in this mapping ?

Thanks in advanced,

Sergio Stateri Jr.
sergio.stateri@globo.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 04, 2007 10:13 am 
Senior
Senior

Joined: Sun Jun 04, 2006 1:58 am
Posts: 136
java persistence with hibernate book has a good section on that.....

Let me know if you cannot get ur hands on that .. i will find other pointers for you

_________________
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 04, 2007 12:50 pm 
Regular
Regular

Joined: Thu Aug 17, 2006 4:50 am
Posts: 55
Location: Mallorca
You have to abandon the many-to-many relationship and create a new Entity for the relation.

This new entity will have to many-to-one relations to Person and Scholl


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.