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: How-to have 2 m-to-m relationships in the same link table ?
PostPosted: Thu Aug 12, 2004 10:26 am 
Newbie

Joined: Thu Dec 18, 2003 4:13 am
Posts: 19
Hello,

I have two classes, A and B which have two kinds of relationships between them. I have the following methods in class A :
public Set getBsRole1()
public Set getBsRole2()


In a previous database model, I had 2 link tables, where each one mapping a relationship. At this stage, it made no problem to use two <set> including a <many-to-many> element in the mapping of class A toward class B.

Now, I would like to have a more compact/normal database design and thus storing both relationships within the same link table using a kind of discriminator as an extra column...

I found some bits of solution using composite-elements. I would have just to create 2 such classes, where one of their property would contain the right discriminator value, but yet the returned sets in class A would contain these composite-elements referencing instances of B, not directly instances of B. So, this solution requieres some uneasy rework in the current application (no compil error, but runtimes errors !).

Does anyone have a better solution ?

Thank you in advance.

Xavier.


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.