-->
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.  [ 5 posts ] 
Author Message
 Post subject: Association mapping on the same table
PostPosted: Fri Jun 01, 2007 9:52 am 
Newbie

Joined: Mon Mar 05, 2007 8:13 am
Posts: 2
Location: Hyderabad
Is it possible to create a mapping association on same table?

I have a user table. The user has friends and this friend is nothing but a user.

Is it possible to do it?

_________________
Kalyan Kumar.C


Top
 Profile  
 
 Post subject: one-to-many relationship
PostPosted: Fri Jun 01, 2007 12:12 pm 
Newbie

Joined: Tue May 08, 2007 12:25 am
Posts: 18
check message below


Last edited by imosquer on Fri Jun 01, 2007 12:19 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: one-to-many relationship
PostPosted: Fri Jun 01, 2007 12:17 pm 
Newbie

Joined: Tue May 08, 2007 12:25 am
Posts: 18
this is possible with a one-to-many relationship. You will however need a table which carries both values.

Code:
<class name="User" table="user">
    <id name="id" column="userId">
        <generator class="native"/>
    </id>
    <set name="friends" table="users_friends">
        <key column="user_id"/>
        <many-to-many column="friend_id"
            unique="true"
            class="User"/>
    </set>
</class>


Notice that by specifying unique="true", we have changed the multiplicity from many-to-many to one-to-many.

hope this helps. let me know =)


Top
 Profile  
 
 Post subject: It helped..
PostPosted: Sat Jun 02, 2007 3:49 am 
Newbie

Joined: Mon Mar 05, 2007 8:13 am
Posts: 2
Location: Hyderabad
Hey it resolved my problem.
Thanks for the quick reply.

_________________
Kalyan Kumar.C


Top
 Profile  
 
 Post subject: I am going to study Medicine in China.
PostPosted: Sat Jun 02, 2007 6:01 am 
Newbie

Joined: Sat Jun 02, 2007 5:57 am
Posts: 1
Hi,

If u are looking to study medicine in some of the best universities in China,
That too when they teach medicine in English,
and also get an oppurtunity to do a part of Clinicals in USA, at a cost 1/5'th of that of USA Medical schools.
Study Medicine in China

Visit: www.chinambbs.com
www.allianceedu.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

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.