This content has been marked as final.
Show 4 replies
-
1. Re: what can be done for not real remove
wolfgangknauf Jul 10, 2007 2:22 PM (in response to john_woo)You remove the phone from the person's phone list, then save the person:
person.getPhones().remove(phone); entityManager.merge (person);
Hope this helps
Wolfgang -
2. Re: what can be done for not real remove
john_woo Jul 10, 2007 3:17 PM (in response to john_woo)"Wolfgang Knauf" wrote:
You remove the phone from the person's phone list, then save the person:person.getPhones().remove(phone); entityManager.merge (person);
Hope this helps
Wolfgang
The API for merge is from http://www.hibernate.org/hib_docs/ejb3-api/
merge(T entity)
Merge the state of the given entity into the current persistence context.
but how about restart jboss, will that person still have the "deleted" phone? -
3. Re: what can be done for not real remove
alexg79 Jul 10, 2007 4:38 PM (in response to john_woo)Please post the code for the "person" entity. The key is how you defined the "phones" collection.
-
4. Re: what can be done for not real remove
waynebaylor Jul 11, 2007 11:42 AM (in response to john_woo)i agree, if you have set CascadeType.ALL or CascadeType.REMOVE on the "phones" collection, then when you call
person.getPhones().remove(phone)
the phone will be removed from the db.
if you only have CascadeType.PERSIST and/or CascadeType.MERGE, then only the "link" from person to that phone will be deleted--the phone entity will still be in the db.