-->
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: Foreign key error / problem with CompositeUserType
PostPosted: Tue Jun 20, 2006 5:12 am 
Newbie

Joined: Thu Sep 29, 2005 9:52 am
Posts: 4
Location: Germany
Hi all,
I got stuck with my mapping, so maybe I can get an answer here. I have two tables (assessment_form and assessment_questions). The first table is identified by three values: assessment_form_cd, assessment_form_c and the language ('de', 'en', 'fr', ...). Now what I want to do is, to load the second table as a List into my object. The rows in the second table can be identified by assessment_form_cd, assessment_form_c and the language.
The UIDType class is a class which implements the CompositeUserType interface, because we use those _cd and _c values to build a unique ID object called UID.
I think that the syntax is correct, but I alsways get this mapping exception:

org.hibernate.MappingException: Foreign key (FK4C78B0C33DA157B:assessment_question [assessment_form_cd,assessment_form_c])) must have same number of columns as the referenced primary key (assessment_form [assessment_form_cd,assessment_form_c,language])

Maybe you see my mistake!?

TIA Tim


Hibernate version:
3.0.5

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<typedef class="biz.solution4your.etutor.dto.database.UidType" name="UID" />

<class name="biz.solution4your.lms.assessment.Assessment" table="assessment_form">

<composite-id>
<key-property name="assessmentId" type="UID">
<column name="assessment_form_cd" />
<column name="assessment_form_c" />
</key-property>
<key-property name="language" column="language"/>
</composite-id>

<many-to-one name="category" not-null="true">
<column name="category_cd"/>
<column name="category_c"/>
</many-to-one>

<many-to-one name="user" not-null="true">
<column name="tutor_cd"/>
<column name="tutor_c"/>
</many-to-one>

<property name="title" column="title"/>
<property name="text" column="text"/>
<property name="privat" column="private"/>

<many-to-one name="translator" class="biz.solution4your.lms.user.User" not-null="true">
<column name="translator_cd"/>
<column name="translator_c"/>
</many-to-one>

<property name="translationDone" column="translation_done"/>

<bag name="questions" table="assessment_question" order-by="number asc">
<key>
<column name="assessment_form_cd"/>
<column name="assessment_form_c"/>
<column name="language"/>
</key>

<one-to-many class="biz.solution4your.lms.assessment.AssessmentQuestion"/>
</bag>

</class>

<class name="biz.solution4your.lms.assessment.AssessmentQuestion" table="assessment_question">
<composite-id>
<key-many-to-one name="assessmentQuestionId" class="biz.solution4your.etutor.dto.database.UidType">
<column name="assessment_question_cd"/>
<column name="assessment_question_c"/>
</key-many-to-one>
<key-property name="language" column="language"/>
</composite-id>

<many-to-one name="assessment" not-null="true">
<column name="assessment_form_cd"/>
<column name="assessment_form_c"/>
</many-to-one>

<property name="language" column="language"/>
<property name="number" column="number"/>
<property name="text" column="text"/>
<property name="points" column="points"/>

</class>
</hibernate-mapping>

Name and version of the database you are using:
MySQL 4.1.13

Mapping Exception:
org.hibernate.MappingException: Foreign key (FK4C78B0C33DA157B:assessment_question [assessment_form_cd,assessment_form_c])) must have same number of columns as the referenced primary key (assessment_form [assessment_form_cd,assessment_form_c,language])


Last edited by Octoate on Tue Jun 20, 2006 11:17 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 20, 2006 5:36 am 
Newbie

Joined: Thu Sep 29, 2005 9:52 am
Posts: 4
Location: Germany
Ok, after trying around, I saw that this lines produces the problem:

Code:
<many-to-one name="assessment" not-null="true">
     <column name="assessment_form_cd"/>
     <column name="assessment_form_c"/>
</many-to-one>


Now I have the problem that - if I add <column name="language"/> to it - I get a exception which says, that "language" isn't mapped in my UidType object (which is true, because it only looks at the _cd and _c values):

org.hibernate.MappingException: An association from the table assessment_question refers to an unmapped class: ....dto.database.UidType

How can I seperate the "language" value from the "UidType" value?


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.