-->
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.  [ 1 post ] 
Author Message
 Post subject: Issues with Merge with Composite key children
PostPosted: Wed Nov 09, 2005 2:46 am 
Newbie

Joined: Thu Aug 25, 2005 10:49 am
Posts: 5
Hi Forum,

I have been using hibernate relationships in my project quite often.
Here is this new issue that I got into. I have given a sample mapping
file.
FIRST_PARENT contains (1-n) SECOND_PARENT, and SECOND_PARENT contains (1-n) FIRST_CHILD(composite keyed) records.

The Scenario is, FirstParent object is already loaded in the session and
I have some new SecondParent objects to add ..so I use merge and everything works fine.
But the moment I add new SecondParent thats has FirstChild objects as list (composite keyed), merge is failing and gives the nullpointerexception..with no stacktrace.

I tried to debug hibernate code and found out it is cribbing for entityName (parameter) to be null in merge method of SessionImpl class.


Is there any basic setting/configration that I m missing ??

Thanks,
Tanya

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 package="test">

<class name="FirstParent" table="FIRST_PARENT">
<id name="firstId" column="FIRST_ID" type="java.lang.Long">
<generator class="native"/>
</id>
<property name="name" column="NAME" type="java.lang.String" not-null="true" />

<bag name="children" cascade="all, delete-orphan" lazy="true" inverse="true">
<key column="ID" not-null="true" update="false"/>
<one-to-many class="SecondParent"/>
</bag>

</class>

<class name="SecondParent" table="SECOND_PARENT">
<id name="secondId" column="SECOND_ID" type="java.lang.Long">
<generator class="native"/>
</id>
<property name="name" column="NAME" type="java.lang.String" not-null="true" />

<bag name="children" cascade="all, delete-orphan" lazy="false" inverse="true">
<key column="SECOND_ID" not-null="true" update="false"/>
<one-to-many class="FirstChild"/>
</bag>
<many-to-one name="firstParent" class="FirstParent" column="FIRST_ID" not-null="true"/>
</class>

<class name="FirstChild" table="FIRST_CHILD">
<composite-id name="id" class="ChildKey">
<key-property name="choice" column="CHOICE" type="java.lang.String"/>
<key-many-to-one name="secondParent" column="SECOND_ID" class="SecondParent"/>
</composite-id>

<property name="sortOrder" column="SORT_ORDER" type="java.lang.Short" />
</class>

</hibernate-mapping>

Name and version of the database you are using: mySql 5.0


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.