-->
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: Design question with many to many relations
PostPosted: Fri Nov 11, 2011 12:40 pm 
Newbie

Joined: Fri Nov 11, 2011 12:26 pm
Posts: 1
Hi,

I'm quite newbie on Hibernate and i would ask you about my db design and if it's make sense or not according to what i would like to get.

Let's say i have two things to manage in my app: people and their relations.
So i have p1 and p2, my two guys. Two people could share several relationships simultaneoulsy: like coworkers, friends, etc.

So until now, i made two tables in my db:
people (people_uuid, name)
relationship (relation_uuid, people1, people2, relation_type)

In my people class, i would like to have a getRelations method, but here comes the trouble: the current guy could be in column people1 or people2 in my relation table, so i don't know how to set the mapping so that when i call my getRelations method, i get every relation (including relations where he's set in people1 column as much as those where he's set in people2 column).
How should i proceed to map this correctly? Is my db design correct, and does it fit to what i want to do with Hibernate?

Thank you very much by advance,

SJ.


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.