• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Hibernate Transaction delete commit fails

Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:

0000002a RegisteredSyn E WTRN0074E:
Exception caught from before_completion synchronization operation: javax.persistence.EntityNotFoundException: deleted entity passed to persist:

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
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?
Damien Fergusson
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:

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.

This should fix the issue.
    Bookmark Topic Watch Topic
  • New Topic