-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Updating Collections
PostPosted: Fri Oct 29, 2010 11:41 pm 
Newbie

Joined: Fri Oct 15, 2010 12:39 am
Posts: 6
Can somebody explain to me how to persist additions and removals to a collection of a parent entity. I want to:

1. outside of a session, add a Person to a Phone entity's Set<Person>
2. update(phone) - and insert a record in a PersonPhone join table
3. remove the newly added Person from the Phone entity's Set<Person>
4. in a separate session, update(phone) - and delete the record from the PersonPhone join table

When I initially load a Phone entity that contains a Set with one Person in it, adding another person to that set flags the set as dirty. The Set<Person> inside the Phone entity has storedSnapshot with a size of 1, which is different than the actual size, which is now 2. So the update succeeds and a new record is inserted into the PersonPhone join table. However, if, using the same entity, I now remove that newly added person, and attempt to update again in a separate session, a delete will not be performed, because the state of the Phone entity once again looks exactly like its storedSnapshot.

I'm still learning about automatic dirty checking, setReadOnly, evict, refresh, and clear. If anyone could give me a leg up, I would really appreciate it. So far, I have not gotten Hibernate to ignore what end up being inaccurate storedSnapshots. Is there a way to force an update in my scenario?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.