Does deleting a relationsip remove the dependant object from the database? [message #654540] |
Wed, 16 February 2011 04:16  |
Eclipse User |
|
|
|
If I have the classic Person entity object, with associated TelephoneNumber objects in a OneToMany relationship, does loading the relationship collection of the parent Person object, then deleting one of the TelephoneNumber objects from this collection and merging the parent object back to the database trigger the deletion of that TelephoneNumber from the database, assuming I have orphanRemoval=true ?
class Person{
....
@OneToMany(mappedBy="telephone", cascade=CascadeType.ALL, orphanRemoval=true)
private Collection<TelephoneNumber> telephoneNumberCollection;
...
}
*************************
Person p=personFacade.getPersonForID(id);
List<TelephoneNumber> lst=p.getTelephoneNumberCollection();
For(TelephoneNumber t:lst){
if(t.getName().equals("Home") lst.remove(t);
}
personFacade.merge(p);
Will this pseudocode result in the removal from the database of the 'Home' telephone number?
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.21038 seconds