About Question enthuware.oce-jpad.v6.2.445 :
Posted: Fri Mar 16, 2012 12:56 am
Hi,
I think the last choice is not correct,
@OneToOne(cascade=CascadeType.REMOVE)
because in the explanation you said that Address will NOT be remove because there is no link between them, I am puzzled.
Situation 2:
Person p = (Person) em.find(Person.class, 1); //find the person with address
Address a = p.getAddress(); //an Address entity also exists for this person
p.setAddress(null);
a.setPerson(null); //required only if it is bidirectional
em.remove(p); //Address a will NOT be removed because there is no link between p and a anymore.
I think the last choice is not correct,
@OneToOne(cascade=CascadeType.REMOVE)
because in the explanation you said that Address will NOT be remove because there is no link between them, I am puzzled.
Situation 2:
Person p = (Person) em.find(Person.class, 1); //find the person with address
Address a = p.getAddress(); //an Address entity also exists for this person
p.setAddress(null);
a.setPerson(null); //required only if it is bidirectional
em.remove(p); //Address a will NOT be removed because there is no link between p and a anymore.