Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Issue with orphanRemoval = true and OptimisticLockException
Issue with orphanRemoval = true and OptimisticLockException [message #1283786] Thu, 03 April 2014 20:34 Go to next message
Dan Mising name is currently offline Dan Mising nameFriend
Messages: 1
Registered: July 2009
Junior Member
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:

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

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

    Thing newThing = new Thing();



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 15:18 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1300
Registered: July 2009
Senior Member
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 Jun 20 15:40:11 GMT 2018

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

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

Back to the top