|
Hi Everyone,
The following is my hibernate mapping file.
<hibernate-mapping> <class name="com.isd.cdm.dao.replicate.Activity" table="VB03ACTV" > <id name="messageID" column="ACTV_ID"> <generator class="assigned"/> </id> <property name="activitySummary" type="java.lang.String"> <column name="ACTVY_SUMMY" length="10"/> </property> <set name="messages" table="VB21AUTR" lazy="false" cascade="all,delete-orphan" > <key column="ACTV_ID" unique="false"/> <one-to-many class="com.isd.cdm.dao.replicate.Message" /> </set> </class> </hibernate-mapping>
<hibernate-mapping> <class name="com.isd.cdm.dao.replicate.Message" table="VB21AUTR" > <composite-id> <key-property name="activityMessageID" column="ACTV_ID" /> <key-property name="systemID" column="HOST_IMS_SYS_ID" /> </composite-id> <property name="activityMessage" type="java.lang.String"> <column name="AUDIT_TRAIL" length="3600"/> </property> </class> </hibernate-mapping>
When I try to save this parent+child I get the following exception.
org.springframework.orm.hibernate3.HibernateSystem Exception: a different object with the same identifier value was already associated with the session: [com.isd.cdm.dao.replicate.Message#com.isd.cdm.dao. replicate.Message@396591ce]; nested exception is org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.isd.cdm.dao.replicate.Message#com.isd.cdm.dao. replicate.Message@396591ce]
The biggest issue is that, this exception occurs only some time, and even it is very diff for me recreate the issue. Googled and found that I need to use saveOrUpdate() / merge() OR remove cascade="all" to fix this. But when I try that I cant recreate the issue.
My question is like, if there is a reference problem, why does it save well sometimes and gets me this error occasionally.
Thanks in advance for your valuable reply.
|