Message Boards

StaleObjectStateException:Row was updated or delted by another transaction

majdi Achouri, modified 3 Years ago.

StaleObjectStateException:Row was updated or delted by another transaction

Junior Member Posts: 38 Join Date: 11/21/19 Recent Posts
Hello Community

I need the help from someone to resolve my issue in liferay 7.3.0 : 

I have a spring batch app which is creating(copying/ updating if exists) users from the back end ( WS database) to the liferay Database portal. 
In the liferay rest portlet which is communicating directly to the back end (spring batch) I have the same issue like in the link ( https://help.liferay.com/hc/en-us/articles/360026807052-ORMException-StaleObjectStateException-is-reported) when executing the

  UserLocalServiceUtil.updateUser(user);


Console trace: 



        Caused by: com.liferay.portal.kernel.dao.orm.ORMException: {"agreedToTermsOfUse":true,"comments":"",at com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl.processException(BasePersistenceImpl.java:446)
Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.liferay.portal.model.impl.UserImpl#38882]
        at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:485)
        at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:255)
        at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:84)
        at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:867)
        at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:851)
        at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:855)
        at com.liferay.portal.dao.orm.hibernate.SessionImpl.merge(SessionImpl.java:241)
        ... 123 more


 How could I fix that ? thanks