-->
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: must have same number of columns as the referenced primary k
PostPosted: Fri Sep 01, 2006 10:24 am 
Newbie

Joined: Mon Aug 28, 2006 4:09 pm
Posts: 6
Well, I have this relationship:

question
PK ano
PK semestre
PK codigo

reply
PK ano
PK semestre
PK cod_question
PK cod_reply

FK
question.ano --> reply.ano
question.semestre --> reply.semestre
question.cod_question --> reply.codigo
FK
type_reply.ano --> reply.ano
type_reply.semestre --> reply.semestre
type_reply.codigo --> reply.cod_reply

type_reply
PK ano
PK semestre
PK codigo

Xml's:

Question:

<hibernate-mapping>
<class
name="custom.entities.dbweb.QuestionarioPergunta"
table="question"
>
<composite-id name="id" class="custom.entities.dbweb.QuestionarioPerguntaId">
<key-property name="ano"
column="ano"/>
<key-property name="semestre"
column="semestre"/>
<key-property name="pergunta"
column="codigo"/>
</composite-id>

!!! Problem!!!
<set name="respostas">
<key>
<column name="ano"/>
<column name="semestre"/>
<column name="codigo"/>
</key>
<many-to-many class="custom.entities.dbweb.QuestionarioResposta">
<column name="cod_reply"/>
</many-to-many>
</set>
</class>
</hibernate-mapping>

Reply:

<hibernate-mapping
>
<class
name="custom.entities.dbweb.QuestionarioResposta"
table="reply"
>
<composite-id name="id" class="custom.entities.dbweb.QuestionarioRespostaId">
<key-property name="ano"
column="ano"/>
<key-property name="semestre"
column="semestre"/>
<key-property name="question"
column="cod_question"/>
<key-property name="reply"
column="cod_reply"/>
</composite-id>

<many-to-one name="question" class="custom.entities.dbweb.QuestionarioPergunta"
update="false"
insert="false"
>
<column name="ano"/>
<column name="semestre"/>
<column name="cod_question"/>
</many-to-one>

<many-to-one name="reply" class="custom.entities.dbweb.TipoResposta"
update="false"
insert="false"
>
<column name="ano"/>
<column name="semestre"/>
<column name="cod_reply"/>
</many-to-one>

</class>

</hibernate-mapping>

type_reply:

<hibernate-mapping
>
<class
name="custom.entities.dbweb.TipoResposta"
table="type_reply"
>
<composite-id name="id" class="custom.entities.dbweb.TipoRespostaId">
<key-property name="ano"
column="ano"/>
<key-property name="semestre"
column="semestre"/>
<key-property name="resposta"
column="codigo"/>
</composite-id>

</hibernate-mapping>

So????


Top
 Profile  
 
 Post subject: The error
PostPosted: Fri Sep 01, 2006 10:48 am 
Newbie

Joined: Mon Aug 28, 2006 4:09 pm
Posts: 6
org.hibernate.MappingException: Foreign key (FK8B2DBD72A6E2ED8E:respostas [cod_reply])) must have same number of columns as the referenced primary key (reply [ano,semestre,cod_question,cod_reply])


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.