Your display should look like this:
public class Parent {
@OneToMany(mappedBy = parent, cascade = CasacadeType.ALL, orphanRemoval = true)
private Set<Child> children = new HashSet<>();
public void removeChild(Child child) {
children.remove(child);
child.setParent(null);
}
}
public class Child {
@ManyToOne
private Parent parent;
}
As explained in this article , since you have bidirectional communication, you must synchronize both sides.
Therefore, it is advisable to call:
parent.removeChild(child);
Therefore, it removeChildis going to draw Childfrom children Setand also establish for Child parentassociation with null.