Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » OptimisticLockException
OptimisticLockException [message #685308] Fri, 17 June 2011 08:36 Go to next message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 807
Registered: July 2009
Senior Member
I'm a bit confused and could use some pointers on where to look. Just now one of my users has gotten this exception:

javax.persistence.OptimisticLockException: Exception [EclipseLink-5010] (Eclipse
Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptio
ns.OptimisticLockException
Exception Description: The object [nl.reinders.bm.Batch@1e91f89&Batchnr=865505]
cannot be merged because it has changed or been deleted since it was last read.
Class> nl.reinders.bm.Batch
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.mergeInternal(
EntityManagerImpl.java:416)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.merge(EntityMa
nagerImpl.java:391)
at nl.knowledgeplaza.util.jpa.EntityManagerExtender.executeDelayedAction
s(EntityManagerExtender.java:187)
at nl.knowledgeplaza.util.jpa.EntityTransactionExtender.invoke(EntityTra
nsactionExtender.java:82)
at $Proxy7.commit(Unknown Source)
at org.tbee.swing.jpa.JpaObjectNavigatorModel$1.call(JpaObjectNavigatorM
odel.java:954)
at org.tbee.swing.jpa.JpaObjectNavigatorModel.doSave(JpaObjectNavigatorM
odel.java:966)
at org.tbee.swing.jpa.JpaObjectNavigatorModel.doSave(JpaObjectNavigatorM
odel.java:907)
at org.tbee.swing.jpa.JpaObjectNavigatorBar$3.actionPerformed(JpaObjectN
avigatorBar.java:171)
....
==== cause:
Local Exception Stack:
Exception [EclipseLink-5010] (Eclipse Persistence Services - 2.0.2.v20100323-r68
72): org.eclipse.persistence.exceptions.OptimisticLockException
Exception Description: The object [nl.reinders.bm.Batch@1e91f89&Batchnr=865505]
cannot be merged because it has changed or been deleted since it was last read.
Class> nl.reinders.bm.Batch
at org.eclipse.persistence.exceptions.OptimisticLockException.objectChan
gedSinceLastMerge(OptimisticLockException.java:145)
at org.eclipse.persistence.internal.sessions.MergeManager.mergeChangesOf
CloneIntoWorkingCopy(MergeManager.java:490)
at org.eclipse.persistence.internal.sessions.MergeManager.mergeChanges(M
ergeManager.java:267)
at org.eclipse.persistence.mappings.CollectionMapping.mergeIntoObject(Co
llectionMapping.java:1404)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.mergeIntoO
bject(ObjectBuilder.java:2678)
at org.eclipse.persistence.internal.sessions.MergeManager.mergeChangesOf
CloneIntoWorkingCopy(MergeManager.java:506)
at org.eclipse.persistence.internal.sessions.MergeManager.mergeChanges(M
ergeManager.java:267)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.mergeCloneWi
thReferences(UnitOfWorkImpl.java:3523)
at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.m
ergeCloneWithReferences(RepeatableWriteUnitOfWork.java:301)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.mergeCloneWi
thReferences(UnitOfWorkImpl.java:3483)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.mergeInternal(
EntityManagerImpl.java:414)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.merge(EntityMa
nagerImpl.java:391)
....


On the batch entity there are Eclipse native events active that update two fields (dwhmodified and dwhby) that hold the timestamp and user of the latest modification.
If I look at these two values:

dwhmodified dwhby
2011-05-18 10:57:02 53

I see that the modified date is almost a month old.

Question: Is it possible that a version of a entity is increased without triggering the insert or update events?

It turns out that this entity should not be involved in this mutation at all, so I need to figure out how and what is done to it. Unfortunately this is one of those once-a-day problems.

Tom
Re: OptimisticLockException [message #685876 is a reply to message #685308] Mon, 20 June 2011 13:32 Go to previous messageGo to next message
Gordon Yorke is currently offline Gordon YorkeFriend
Messages: 77
Registered: July 2009
Member
It is possible for the application to update the Version attribute of the Entity. The exception is occurring when an Entity is being merged into an active Persistence Context. Is it possible a flush is occurring on the Persistence Context and then a merge is occurring with the original version value read within that transaction? In EclipseLink a flush will increment the version value.
Re: OptimisticLockException [message #686475 is a reply to message #685308] Wed, 22 June 2011 09:38 Go to previous message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 807
Registered: July 2009
Senior Member
Let me re-ask my core question: Is it possible that a version of a entity is increased without triggering the insert or update events?
Previous Topic:Memory leak/control overhead
Next Topic:(no subject)
Goto Forum:
  


Current Time: Fri Nov 21 02:28:52 GMT 2014

Powered by FUDForum. Page generated in 0.08862 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software