-->
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.  [ 4 posts ] 
Author Message
 Post subject: many-many relationship with mapping table
PostPosted: Thu May 21, 2009 6:03 pm 
Newbie

Joined: Thu May 21, 2009 5:54 pm
Posts: 2
I have two tables that are related via a mapping table. The mapping table actually holds the ParentKey & ChildKey. I mapped them without having to have a class for the Mapping table as said in http://codebetter.com/blogs/peter.van.ooijen/archive/2008/05/29/nhibernate-many-to-many-collections-or-mapping-is-not-one-table-one-class.aspx

In my case many objects relate to one child table.
Table1 ---->
Table2 ----> MappingTable ----> ChildTable
Table3 ---->

My mapping table contains "ParentKey" (table1_PK or table2_PK or table3_PK) and childKey (ChildTable_PK).

Now I have to add a "parenttype" column to the mapping table. How can i possibly do that?
Any help is appreciated.


Top
 Profile  
 
 Post subject: Re: many-many relationship with mapping table
PostPosted: Fri May 22, 2009 2:03 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
You need to model a class for the mapping table.

Table 1 1:* MappingTable *:1 ChildTable

_________________
--Wolfgang


Top
 Profile  
 
 Post subject: Re: many-many relationship with mapping table
PostPosted: Fri May 22, 2009 2:54 pm 
Newbie

Joined: Fri May 22, 2009 2:49 pm
Posts: 2
Is it not possible to do this without mapping the 'link' table. I guess I'm missing something but as I currently understand it, if I have to a add a class for the link table then my object model starts to look like my database?


Top
 Profile  
 
 Post subject: Re: many-many relationship with mapping table
PostPosted: Mon May 25, 2009 2:44 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Not that I know of. You have to map the link table.

_________________
--Wolfgang


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.