Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » Issue with orphanRemoval = true and OptimisticLockException
Issue with orphanRemoval = true and OptimisticLockException [message #1283786] Thu, 03 April 2014 16:34 Go to next message
Eclipse UserFriend
I have a @OneToMany with orphanRemoval = true on an entity attribute. I want to delete the contents of the collection and replace it with new items. My code looks like:

@Transactional
public doit(Long id) {
    MyEntity e = findEntity(id);

    List<Thing> things = e.getThings();
    things.clear();

    Thing newThing = new Thing();
    newThing.merge();

    things.add(newThing);

    e.merge();
}

In that example, the MyEntity.things collection is the @OneToMany with orpahnRemoval. It seems that at both lines were merge() is called, EclispeLink calls CommitManager.deleteAllObjects(). So the when the newThing is merged it deleted the contents of things that was cleared. When e is merged, it tries to delete again and throws OptimisticLockException.

Has anyone seen this before?

Thank you!
Re: Issue with orphanRemoval = true and OptimisticLockException [message #1290936 is a reply to message #1283786] Thu, 10 April 2014 11:18 Go to previous message
Eclipse UserFriend
newThing is a new instance of Thing, why would it affect MyEntity's things list? What does your Thing.merge() and MyEntity.merge() methods do? Can you show the SQL statements that are issued for this transaction?
Previous Topic:don't get latest data from database
Next Topic:EclipseLink memory leak?
Goto Forum:
  


Current Time: Wed Jul 16 07:23:45 EDT 2025

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

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

Back to the top