-->
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 XML mapping incorrect
PostPosted: Wed Aug 03, 2005 4:13 pm 
Newbie

Joined: Tue Aug 02, 2005 1:54 pm
Posts: 2
My original problem was that when performing a save() on my child object, it kept trying to UPDATE instead of INSERT. So I thought the issue might be solved by placing parent/child parameters in my XML files. I'm now getting an error that my XML is mapped incorrectly. Any help?

--------PARENT-----------

<?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>
<class name="com.bkv.search.objectmodel.Keyword" table="Keywords">
<composite-id>
<key-many-to-one name="client" class="com.bkv.search.objectmodel.Client" column="clientName"/>
<key-property name="keywordName"/>
</composite-id>
<set name="keywordBuy" table="KeywordBuys" lazy="false" cascade="all" inverse="true" >
<key column="keywordName"/>
<key column="clientName" />
<one-to-many class="com.bkv.search.objectmodel.KeywordBuy"/>
</set>
<property name="groupName"/>
<many-to-one name="department" class="com.bkv.search.objectmodel.Department" column="deptName"/>
<property name="campaign"/>
<many-to-one name="category" class="com.bkv.search.objectmodel.Category" column="categoryName"/>
</class>
</hibernate-mapping>


--------------CHILD--------------------------

<?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>
<class name="com.bkv.search.objectmodel.KeywordBuy" table="KeywordBuys">
<id name="buyId">
<generator class="increment"/>
</id>
<property name="buyTime"/>
<property name="campaign"/>
<property name="url"/>
<many-to-one name="keyword" class="com.bkv.search.objectmodel.Keyword" not-null="true">
<column name="clientName"/>
<column name="keywordName"/>
</many-to-one>
<many-to-one name="searchEngine" class="com.bkv.search.objectmodel.SearchEngine" insert="false" update="false">
<column name="clientName" />
<column name="searchEngineName"/>
</many-to-one>
<many-to-one name="matchType" class="com.bkv.search.objectmodel.MatchType" column="matchTypeName"/>
<many-to-one name="placement" class="com.bkv.search.objectmodel.Placement" column="placementName"/>
<many-to-one name="status" class="com.bkv.search.objectmodel.Status" column="statusName"/>
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject: tip
PostPosted: Wed Aug 03, 2005 5:34 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
try setting for you child id
if id is primitive
<id name="buyId" unsaved-value="0" >
<generator class="increment"/>
</id>
or if id is object
<id name="buyId" unsaved-value="null" >
<generator class="increment"/>
</id>


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.