-->
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.  [ 2 posts ] 
Author Message
 Post subject: Transaction delete commit fails with EntityNotFoundException
PostPosted: Thu Aug 04, 2011 11:29 am 
Newbie

Joined: Tue Jun 27, 2006 7:35 pm
Posts: 3
We have a business usecase where we need to delete a set of rows in a transaction!
The Object graph is very simple. Object 1 has CASCADE ALL as its attribute FYI:

Object 1 > One-to-Many > Object 2
We need to delete Object 2 entries.

On a local integration testing environment - we use org.springframework.transaction.jta.JtaTransactionManager for deleting the Hibernate entities - which works.
However, when deployed on the server, we use org.springframework.transaction.jta.WebSphereUowTransactionManager which throws this error:
Quote:
0000002a RegisteredSyn E WTRN0074E:
Exception caught from before_completion synchronization operation: javax.persistence.EntityNotFoundException: deleted entity passed to persist:

[com.cmb.businessengine.apps.fileimport.core.domain.FileImportStatistics#<null>]
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614)
at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:525)
at org.hibernate.transaction.WebSphereExtendedJTATransactionLookup$TransactionManagerAdapter$TransactionAdapter$1.invoke
(WebSphereExtendedJTATransactionLookup.java:142)
at $Proxy98.beforeCompletion(Unknown Source)
at com.ibm.ws.jtaextensions.SynchronizationCallbackWrapper.beforeCompletion(SynchronizationCallbackWrapper.java:65)
at com.ibm.ws.Transaction.JTA.RegisteredSyncs.distributeBefore(RegisteredSyncs.java:242)
at com.ibm.ws.Transaction.JTA.TransactionImpl.prePrepare(TransactionImpl.java:2449)
at com.ibm.ws.Transaction.JTA.TransactionImpl.stage1CommitProcessing(TransactionImpl.java:1675)
at com.ibm.ws.Transaction.JTA.TransactionImpl.processCommit(TransactionImpl.java:1646)
at com.ibm.ws.Transaction.JTA.TransactionImpl.commit(TransactionImpl.java:1581)
at com.ibm.ws.Transaction.JTA.TranManagerImpl.commit(TranManagerImpl.java:247)
at com.ibm.ws.Transaction.JTA.TranManagerSet.commit(TranManagerSet.java:168)
at com.ibm.ws.uow.UOWManagerImpl.uowCommit(UOWManagerImpl.java:1056)
at com.ibm.ws.uow.UOWManagerImpl.uowEnd(UOWManagerImpl.java:1026)
at com.ibm.ws.uow.UOWManagerImpl.runUnderNewUOW(UOWManagerImpl.java:976)
at com.ibm.ws.uow.UOWManagerImpl.runUnderUOW(UOWManagerImpl.java:510)
at org.springframework.transaction.jta.WebSphereUowTransactionManager.execute(WebSphereUowTransactionManager.java:252)


Can anyone suggest why it would pass when using org.springframework.transaction.jta.JtaTransactionManager but fails when using org.springframework.transaction.jta.WebSphereUowTransactionManager?


Top
 Profile  
 
 Post subject: Re: Transaction delete commit fails with EntityNotFoundException
PostPosted: Mon Aug 08, 2011 11:54 am 
Newbie

Joined: Tue Jun 27, 2006 7:35 pm
Posts: 3
I managed to figure out what was wrong - pretty silly really!!
Anyways - posting here so anyone googling this issue might find this of help.

I was deleting the Object 2 thus:
Code:
em.delete(Object 2)


However, I wasn't disassociating the Object 2 from Object 1 as well.
Before commit at anytime, in addition to deleting the target Object from the Entity Manager above, disassociate the Objects you are deleting from the parent object in the memory as well and this problem goes away.

Code:
object1.getAllObject2().remove(object2);

This should fix the issue.


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

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.