-->
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.  [ 2 posts ] 
Author Message
 Post subject: how to map a foreign key which combines two primary keys
PostPosted: Sun Sep 11, 2005 8:02 pm 
Newbie

Joined: Sun Sep 11, 2005 7:46 pm
Posts: 15
Hi folks,

I have three classes: Survey.java, Question.java and Answer.java. The multiplicity between Survey.java and Question.java is many-to-many. The ANSWER table should has its own primary key, and there should also be a foreign key (or two?) which combines the primary keys of table SURVEY (SURVEY_ID) and QUESTION (QUESTION_ID). The table SURVEY_QUESTION will be automatically created since I declared it in both Survey.hbm.xml and Question.hbm.xml. How should I write the mapping declarations in the Answer.hbm.xml for the foreign key mappying? Any help or advice would be highly appreciated!

Regards,
Ellen


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 12, 2005 11:41 am 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
Code:
<composite-id>
         <key-property name="id" column="ID" type="java.lang.String"/>
         <key-many-to-one name="survey" column="SURVEY_ID" />
         <key-many-to-one name="question" column="QUESTION_ID" />
      </composite-id>


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