Hi
In my case I need invoke flush
method on entityManager
before accept transaction. When I invoke this method I get error like below. When I removeentityManager.flush();
transaction is accept normally. I update entity Documents once on the end of process. Where can I search solving this problem ?
Caused by: org.eclipse.persistence.exceptions.OptimisticLockException:
Exception Description: The object [com.company.erp.entity.documents.Documents-27005 [detached]] cannot be merged because it has changed or been deleted since it was last read.
Class> com.company.erp.entity.documents.Documents
at org.eclipse.persistence.exceptions.OptimisticLockException.objectChangedSinceLastMerge(OptimisticLockException.java:152) ~[eclipselink-2.6.2.cuba24.jar:2.6.2.cuba24]
at org.eclipse.persistence.internal.sessions.MergeManager.mergeChangesOfCloneIntoWorkingCopy(MergeManager.java:578) ~[eclipselink-2.6.2.cuba24.jar:2.6.2.cuba24]
at org.eclipse.persistence.internal.sessions.MergeManager.mergeChanges(MergeManager.java:313) ~[eclipselink-2.6.2.cuba24.jar:2.6.2.cuba24]
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.mergeCloneWithReferences(UnitOfWorkImpl.java:3569) ~[eclipselink-2.6.2.cuba24.jar:2.6.2.cuba24]
at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.mergeCloneWithReferences(RepeatableWriteUnitOfWork.java:387) ~[eclipselink-2.6.2.cuba24.jar:2.6.2.cuba24]
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.mergeCloneWithReferences(UnitOfWorkImpl.java:3529) ~[eclipselink-2.6.2.cuba24.jar:2.6.2.cuba24]
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.mergeInternal(EntityManagerImpl.java:553) ~[eclipselink-2.6.2.cuba24.jar:2.6.2.cuba24]