-->
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: many-to-one with composit_id
PostPosted: Mon Apr 19, 2004 10:48 am 
Newbie

Joined: Tue Feb 03, 2004 11:58 am
Posts: 11
I have to objects to map as one-to-many and many-to-one bidirectional relationship.
Both of them have composite id as an identifier.
The first one, "Template" contains a set of "Groups", which is the other one.
The Template.java looks like this:
Code:
       ...
       private Set groups;
       ...
       //getter/setter methods here
       ...

So in the Template.hbm.xml I have
Code:
        <set name="groups">
           <key>
                           <column name="TMPL_ID"/>
              <column name="TMPL_VER"/>
           </key>
   <one-to-many class="Group"/>
        </set>

I hope that this is correct.
The Group.java looks like this:
Code:
       ...
       private Template template;;
       ...
       //getter/setter methods here
       ...


Now I have a problem mapping many-to-one relationship from Group to Template?
How do I go, with two many-to-one statements with the same class="" value, same name="" values, just the column="" different, or do I do it differently.

Please help.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 19, 2004 10:55 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Use one many-to-one element with two nested column elements. Note that the order has to be the same as the order of your key-propertys.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 19, 2004 11:30 am 
Newbie

Joined: Tue Feb 03, 2004 11:58 am
Posts: 11
Thanks


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.