Joined: Thu Dec 08, 2011 11:31 pm Posts: 3
|
Hi all,
I have a problem with OptimisticLockException and StaleObjectStateException in my application. Only happens recently. Below is the flow of entity manager usage during the transaction. Need your help to point out the mistake. Kinda stuck here..
ublic A print(A a) { B b = a.getB(); update (a);
em.merge(b); em.flush();
a.setB(b);
if (...) { a = issue(a); } return a; }
public A update(A a) { ... B b = a.getB(); em.merge(b); a.setB(b); return a; }
public A issue(A a) { B b = a.getB(); em.merge(b); em.flush(); a.setB(b); return a; }
and these are snippets of the stack trace.
Caused by: javax.persistence. at org.hibernate.ejb.AbstractEntityManagerImpl.wrapStaleStateException(AbstractEntityManagerImpl.java:627) at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:588) at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:244) at com.ibm.ws.jpa.management.JPAExEmInvocation.merge(JPAExEmInvocation.java:324) at com.ibm.ws.jpa.management.JPAEntityManager.merge(JPAEntityManager.java:136) at allianz.ejb.service.cnote.allianzshield.CnasNoteServiceImpl.issueCnasNote(CnasNoteServiceImpl.java:742) ... 53 more Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [allianz.ejb.entity.cnote.productName.B#PAS00000402] <--- i changed the object name to B at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:418) at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:234) at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:84) at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:705) at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:689) at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:693) at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:235) ... 56 more
Please help
|
|