-->
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 reference problem***
PostPosted: Fri Sep 05, 2008 2:12 pm 
Newbie

Joined: Tue Jun 10, 2008 12:39 pm
Posts: 14
Hi,

<hibernate-mapping>
<class name="adaptation.data.extract.SchemeExtract" table="scheme_extract" optimistic-lock="version">

<id name="id" column="scheme_extract_id" >
<generator class="increment"/>
</id>
<property name="schemeId" column="scheme_id" not-null="true" />

<property name="lastGoodDate" column="last_good_date"/>
<property name="lastGoodSequence" column="last_good_sequence"/>
<property name="nextDueDate" column="next_due_date"/>
<property name="nextDueSequence" column="next_due_sequence"/>
<property name="lastSuccessCount" column="last_success_count"/>
<property name="lastFailureCount" column="last_failure_count"/>

<set name="missingExtracts" lazy="false">
<key column="scheme_extract_id" not-null="true"/>
<one-to-many class="adaptation.data.extract.ExtractMissing" />
</set>

<many-to-one name="extract" column="extract_id" class="adaptation.data.extract.Extract" not-null="true" lazy="false" />
</class>
</hibernate-mapping>


<hibernate-mapping>
<class name="adaptation.data.extract.ExtractMissing" table="missing_extract_file" dynamic-update="true" optimistic-lock="version">

<id name="id" column="scheme_extract_id" unsaved-value="null">
<generator class="increment"/>
</id>
<property name="expectedDate" column="expected_date" />
<property name="expectedSequence" column="expected_sequence"/>
</class>
</hibernate-mapping>


EXCEPTION :


org.hibernate.MappingException: Foreign key (FK315B58B3C22D0F39:missing_extract_file [scheme_extract_id])) must have same number of columns as the referenced primary key (scheme_extract [scheme_id,extract_id])

can u please help me out...
_________________
Thanks
Babu

_________________
Thanks
Babu


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 09, 2008 7:46 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Your primary key is a compound key, but the foreign key doesn't share the same number of properties as the compound key. I think that's the problem.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


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.