In case of "orphanRemoval=true" the "remove" is not necessary, just commit of transaction will remove the Address:
Code: Select all
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);
// NOT NEEDED a.setPerson(null);
// NOT NEEDED em.remove(p);
<commit at some time>