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: NonUniqueObjectException while using CompositeKey
PostPosted: Tue May 12, 2009 10:27 am 
Newbie

Joined: Tue May 12, 2009 10:17 am
Posts: 1
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.


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.