Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Replacing collections
Replacing collections [message #385417] Fri, 30 January 2009 23:13 Go to next message
David J Rericha is currently offline David J RerichaFriend
Messages: 13
Registered: July 2009
Junior Member
Dear members,

In my application, the user will edit a medical claim which has a
OneToMany association with diagnoses. Because the user can do all manner
of changes to the claim-diagnoses list, before saving the claim, I simply
clear the collection and insert the changed list. I am using
@PrivateOwned to perform the deletions. However, since the default
operation order is inserts, updates, and deletes, my inserted diagnoses
are deleted ( identity is a composite key of claim-id and diagnosis-id ).
I discovered UnitOfWork.shouldPerformDeletesFirst(), but I doesn't make
any difference. The claim-diagnoses (claimIcdms) are inserted and then

UnitOfWork uow = (UnitOfWork)( (JpaEntityManager)em.getDelegate()
).getActiveSession( em );
em.persist( claim );

@Table( name = "moms_claim" )
public class Claim extends MOMSEntity
@OneToMany(mappedBy = "claim", cascade = { ALL })
private List<ClaimIcdm> claimIcdms = new ArrayList<ClaimIcdm>();
Re: Replacing collections [message #385422 is a reply to message #385417] Mon, 02 February 2009 13:24 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Having two objects with the same Id in the same transaction is a very bad
idea. You might try to merge() the changes in the object to allow an
update (or nothing if not changed) instead of a full delete and

Otherwise you could remove everything, then flush() then re persist them.
Or use two separate transactions.


James : Wiki : Book : Blog : Twitter
Previous Topic:OneToMany associations
Next Topic:JPA: order by length?
Goto Forum:

Current Time: Mon Jun 18 14:01:52 GMT 2018

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

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

Back to the top