-->
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: OptimisticLockException and StaleObjectStateException
PostPosted: Fri Dec 09, 2011 2:28 am 
Newbie

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


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.