-->
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: many-to-many relation with composite Ids
PostPosted: Fri Mar 05, 2004 1:17 pm 
Newbie

Joined: Thu Mar 04, 2004 5:05 pm
Posts: 2
Hi , I have some problem mapping a many-to-many relation with the latest version of hibernate.

Table Question:

- Key1, pageId, questionId (compose the key)
- Some attributes

Table Reponses:

- Key1, pageId, questionId, responseId (compose the key)
- Some attributes


Relation Table called validResponses:

- Key1, pageId, questionId, responseId (compose the key)
- no attributes

* Key1 is the same for every table


I would like to have a Set of Response objects in the question object representing all the valid responses for a question but I can't find a way to map this many-to-many relation in my question.hbm.xml file.


I tried something like :


<set name="validResponses" table="valid_response" >
<key>
<column name="content_id"/>
<column name="page_id"/>
<column name="question_id"/>
</key>
<many-to-many class="questionnaire.bean.Response" >
<column name="content_id"/>
<column name="page_id"/>
<column name="question_id"/>
<column name="response_id"/>
</many-to-many>
</set>



But I got this error :

java.lang.RuntimeException: Exception building SessionFactory: Repeated column in mapping for collection: questionnaire.bean.Question.validResponses column: key1


Any idea ?


Top
 Profile  
 
 Post subject: fix to the original message
PostPosted: Fri Mar 05, 2004 1:21 pm 
Newbie

Joined: Thu Mar 04, 2004 5:05 pm
Posts: 2
Sorry , the mapping is this one :


<set name="validResponses" table="valid_response" >
<key>
<column name="key1"/>
<column name="page_id"/>
<column name="question_id"/>
</key>
<many-to-many class="questionnaire.bean.Response" >
<column name="key1"/>
<column name="page_id"/>
<column name="question_id"/>
<column name="response_id"/>
</many-to-many>
</set>


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.