-->
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: [New]Problem: Many-to-Many with extra columns, with a twist.
PostPosted: Mon May 24, 2010 4:52 pm 
Newbie

Joined: Mon May 24, 2010 3:28 pm
Posts: 1
So, this is probably a very common question, except for the twist.

I need to map a many-to-many association between 2 objects(let's call em Person, Address), and have extra columns on the new table.

I read about how to do it, you have to create a new POJO(PersonAddress) for the new table, give it its own ID, the columns you want, and many-to-one associations with each type of Object that participates, then go to the other 2 objects and fix one-to-manys with foreign keys pointing to the new object.

So far, so good. Here's the twist.

What happens if the 2 Objects that were to be associated are both Person tho? The new POJO will be PersonPerson and have 2 many-to-ones to Person, and Person will have 1 or 2 List<PersonPerson> one-to-many ?

Is that List even necessary or just there for bi-directionality?


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.