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
|