-->
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.  [ 3 posts ] 
Author Message
 Post subject: Table maps back to itself?
PostPosted: Thu Jul 27, 2006 5:11 pm 
Beginner
Beginner

Joined: Sat Jul 08, 2006 2:58 pm
Posts: 26
How would I do this?

Suppose I have a table called Person which has a column called Friends which is a set of Persons, like this:

Code:
Person {
  Long id
  Set<Person> friends;
       .
       .
       .
}


What would the mapping file look like? Is this a bad idea to do this??


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 27, 2006 6:21 pm 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
This is no problem at all. Just map it as you would map any other set as described in
http://www.hibernate.org/hib_docs/v3/re ... l-join-12m

_________________
Please don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 27, 2006 6:41 pm 
Beginner
Beginner

Joined: Sat Jul 08, 2006 2:58 pm
Posts: 26
So would the mapping file look like this?


Code:
<class name="Person">
    <id name="id" column="personId">
        <generator class="native"/>
    </id>
    <set name="friends" table="Person">
        <key column="personId"/>
        <element  type='long" column="Friends" unique="true" class="Person"/>
    </set>
</class>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.