Issue with orphanRemoval = true and OptimisticLockException [message #1283786] |
Thu, 03 April 2014 16:34  |
Eclipse User |
|
|
|
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!
|
|
|
|
Powered by
FUDForum. Page generated in 0.07416 seconds