Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Unexpected OptimisticLockException on merge()

Hello Michael,

Using the object after merge might cause the issue - the version in the managed object will get updated, but the detached copy will remain the same after the commit.  This will cause it to appear stale if you attempt to make changes and merge it in later.  I would recommend passing back or finding the managed object when the transaction completes to avoid the exception.

Best Regards,
Chris

----- Original Message -----
From: michael.simons@xxxxxxxxxxx
To: eclipselink-users@xxxxxxxxxxx
Sent: Thursday, December 31, 2009 5:51:50 AM GMT -05:00 US/Canada Eastern
Subject: [eclipselink-users] Unexpected OptimisticLockException on merge()

Hello,

When merging an instance within my program a OptimisticLockException is thrown, although there's
no one else accessing neither the database nor the record updated by the program:

Exception Description: The object [net.uniopt.domain.ot.Depot@ffae4c] cannot be merged because
it has changed or been deleted since it was last read.
Class> net.uniopt.domain.ot.Depot
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.mergeInternal
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.merge

I guess the exception is thrown because there's already a managed instance (the one that was
returned by merge() and updated) and now I again try to merge an unmerged instance with the same
id.

Might this be the reason for the exception?
If not, what might cause this behaviour?

- Michael
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top