-->
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: Mapping a set with multiple-fields key
PostPosted: Mon Mar 19, 2007 8:06 am 
Newbie

Joined: Mon Sep 25, 2006 8:35 am
Posts: 5
I have a table "Questions" with a key formed by fields "id_question" and "id_prog_question" (a counter).
Each question may have a set of children questions, bounded to the parent question by a key formed by fields (parent_id,parent_prog). How can I model this set?

<class name="Questions" table="questions">
<composite-id name="id" class="QuestionsKey">
<key-property name="id_question" column="id_question" type="java.lang.Integer" />
<key-property name="id_prog_question" column="id_prog_question" type="java.lang.Integer" />
</composite-id>
...
<set name="childrenquestions" inverse="true" lazy="false">
<key column="parent_id" />
<key column="parent_prog" />
<one-to-many class="Questions" />
</set>
</class>

this doesnt work. Must I define a "ChildrenQuestionsKey" element containing the two fields parent_id and parent_prog? please help
thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 19, 2007 9:40 am 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
Try:

Code:
<set ...>
  <key>
    <column name="parent_id"/>
    <column name="parent_prog"/>
  </key>
</set>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 19, 2007 10:35 am 
Newbie

Joined: Mon Sep 25, 2006 8:35 am
Posts: 5
it works! thank you


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.