Hi,
I am getting below exception inconsistently when we trying to persist multiple records at a single transaction.
Caused by: org.hibernate.HibernateException: identifier of an instance of Test was altered from 7 to 79 at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:85) at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:190) at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:147) at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:219) at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99) at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:58) at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:1185) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1261) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
I have pasted the hbm files below. Can anyone please help me to get out of this issue.
1.Test.hbm.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping> <class name="Test" abstract="true">
<!--Id--> <id name="testId" column="TEST_ID" type="long"> <generator class="native" /> </id>
<!--Properties--> <property column="PARENT" name="parentName" type="string" /> </class> </hibernate-mapping>
2. SubTest.hbm.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping> <union-subclass name="SubTest" extends="Test" table="Test" >
<!--Mapping b/w other tables--> <set name="testSet" inverse="true" cascade="save-update, delete-orphan"> <key column="TEST_ID" /> <one-to-many class="TestData" /> </set>
</union-subclass> </hibernate-mapping>
3. ParentTestData.hbm.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping> <class name="ParentTestData" abstract="true"> <!--Id--> <id name="parentTestId" column="PATRENT_VALUE_ID" type="long"> <generator class="native"/> </id> <!--Properties--> <property name="keyString" column="KEY_STRING" type="string"/> </class> </hibernate-mapping>
4. TestData.hbm.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping> <union-subclass name="TestData" extends="ParentTestData" table="TEST_VALUE"> <!--Mapping b/w other tables--> <many-to-one name="myTest" column="TEST_ID" not-null="true"/> </union-subclass> </hibernate-mapping>
Regards, Riyas[code][/code]
|