Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] [ClassName] cannot be merged because it has changed or been deleted since it was last read

Turns out this was my mistake. I was trying to merge() a non-persistent
object.

This brings up the question, is there a method that takes in an Entity and
calls persist() if it's non-persistent and merge() if it is? Sort of like
Hibernate's Session.saveOrUpdate() method.

Thanks,
Gili


cowwoc wrote:
> 
> Hi,
> 
> I retrieve an Entity from the DB, modify it then invoke
> EntityManager.merge() on it. For some reason EclipseLink throws this
> exception:
> 
> javax.persistence.OptimisticLockException: Exception [EclipseLink-5010]
> (Eclipse Persistence Services - 1.0 (Build 1.0 - 20080707)):
> org.eclipse.persistence.exceptions.OptimisticLockException
> Exception Description: The object [Object.toString() goes here] cannot be
> merged because it has changed or been deleted since it was last read.
> {3}Class> [className goes here]
> 
> I'm confused. Isn't the entire point of EntityManager.merge() to push
> changes from the in-memory entity back to the database? Shouldn't this
> work?
> 
> Thank you,
> Gili
> 

-- 
View this message in context: http://www.nabble.com/-ClassName--cannot-be-merged-because-it-has-changed-or-been-deleted-since-it-was-last-read-tp19465366p19465510.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top