Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Getting OptimisticLockException on new Entity
Getting OptimisticLockException on new Entity [message #535847] Wed, 26 May 2010 01:12 Go to next message
Will Hartung is currently offline Will HartungFriend
Messages: 4
Registered: March 2010
Junior Member
I'm creating an entity.

It is MOSTLY all new (no primary key), however there are some child elements that are not new, they're existing, persisted objects.

When I try and save the object using EntityManager.merge, I get:

e
Caused by: Exception [EclipseLink-5010] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.OptimisticLockException
Exception Description: The object [entities.Task@0] cannot be merged because it has changed or been deleted since it was last read.

Task itself is the new object, and none of the children objects are changed during this process.

I have logging set to FINE, but see no DB activity at this point.

I've checked all my sequences, and it doesn't look like I'm trying to reuse a sequence number (i.e. my new sequence results in a key that already exists in the DB).

Any thoughts appreciated.

[Updated on: Wed, 26 May 2010 01:12]

Report message to a moderator

Re: Getting OptimisticLockException on new Entity [message #536065 is a reply to message #535847] Wed, 26 May 2010 20:23 Go to previous message
Will Hartung is currently offline Will HartungFriend
Messages: 4
Registered: March 2010
Junior Member
I figured it out. Someone decided that setting the rowVersion column (which is annotated with @Version in our entity) with a 1 in the constructor was a Good Idea.

It's not.
Previous Topic:EclipseLink 1.2.0 Workbench usage
Next Topic:Problem with DescriptorEventAdapter and EJBContext
Goto Forum:
  


Current Time: Fri Apr 26 12:39:10 GMT 2024

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

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

Back to the top