-->
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: Parent Child and Foreign key reference
PostPosted: Fri Oct 10, 2003 8:33 am 
Newbie

Joined: Wed Oct 01, 2003 8:56 am
Posts: 6
Hi All

I am sure that this has been covered before, and I have read the Parent/Child doc.

But I am getting the following error:

key referenced from consumer_contact not found in consumer_brand

I am working against an postgresql db, and use SEQUENCE to generate the id's.

Now I am adding a new parent, and a new child, and I have added the child object to the parent, and the parent object to the child.

Any pointers would be helpful.

thanks
Jeff Singer

Here are snippets from my meta files:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<!--
Created by Middlegen Hibernate plugin

http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->
<class name="za.co.vine.consumerManagement.binding.hibernate.ConsumerBrand" table="consumer_brand">
<id name="consumerBrandId" type="int" column="consumer_brand_id">
<generator class="sequence">
<param name="sequence">hibernate_sequence</param>
</generator>
</id>
<property name="permission" type="boolean" column="permission" length="1"/>
<property name="dateRecruited" type="java.sql.Date" column="date_recruited" length="4"/>
<!-- bi-directional one-to-many association to ConsumerContact -->
<set name="consumerContacts" inverse="true" cascade="all">
<key column="consumer_brand_id" />
<one-to-many class="za.co.vine.consumerManagement.binding.hibernate.ConsumerContact"/>
</set>

</class>
</hibernate-mapping>


and

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<!--
Created by Middlegen Hibernate plugin

http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->
<class name="za.co.vine.consumerManagement.binding.hibernate.ConsumerContact" table="consumer_contact">
<id name="consumerContactId" type="int" column="consumer_contact_id">
<generator class="sequence">
<param name="sequence">hibernate_sequence</param>
</generator>
</id>
<property name="contact" type="java.lang.String" column="contact" length="-1"/>
<property name="incorrectContactCount" type="java.math.BigDecimal" column="incorrect_contact_count" length="65535"/>
<property name="optIn" type="boolean" column="opt_in" length="1"/>
<!-- associations -->
<!-- bi-directional many-to-one association to ConsumerBrand -->
<many-to-one name="consumerBrand" class="za.co.vine.consumerManagement.binding.hibernate.ConsumerBrand" not-null="true" cascade="all" column="consumer_brand_id" />
<!-- bi-directional many-to-one association to ContactType -->
<many-to-one name="contactType" class="za.co.vine.consumerManagement.binding.hibernate.ContactType" not-null="true" cascade="all">
<column name="contact_type_id"/>
</many-to-one>
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 10, 2003 9:10 am 
Regular
Regular

Joined: Tue Aug 26, 2003 7:53 pm
Posts: 66
Location: Lakeland, Florida USA
Not sure if this is the problem but have you looked at the many-to-one insert/update attributes (see sec 4.1.10 in ref)? Aren't you getting mapping warnings/errors from Hibernate to this effect?

Jeff


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.