-->
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 model a symmetric self-referencing relation?
PostPosted: Wed Feb 11, 2009 4:38 pm 
Newbie

Joined: Mon Dec 29, 2008 2:20 pm
Posts: 5
Hi,

I am trying to model a friendship relation between User entities. My initial impression was that this should be modeled as a bidirectional m:n relation, much like a parent-child self-reference. But in this case, the roles on both sides of the relation are the same.

In the database schema, I have a join table that basically consists of (user1_id, user2_id). How can I map this relation in the user class so the friends set of a user contains all friends, no matter in which column the user's id is?

In general, are there other ways of accomplishing this in the relational schema? (Although in this case, unfortunately, I have to deal with a legacy schema...)

Thanks,

Michael


Sorry for posting twice... this one can be deleted...


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.