-->
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: About mapping a entity inside itself
PostPosted: Sat Dec 18, 2010 1:19 am 
Newbie

Joined: Sat Dec 18, 2010 1:11 am
Posts: 1
Hello, sorry the poor english.

Well, I'm doing a little project where I have a entity name User, and this is mapped ok.

But I want increment adding a following idea:
- A User can be friend of other User, in other words, a User can have a list of User (friends)

In MySQL table, I create a table User, i'ts ok, and I create other table name friend which I put two primary keys, the id of the user and the id of the friend, like this:
--------
| 1 | 2 |
--------

I wonder, how can I do this using just hibernate? Something like: "From User Inner Join Friend On (User.id = Friend.id_primary And Friend.id_secundary = 1)" (in case, "1" is the id of the User that I want retrieve the friends...

Thanks anyway :)


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.