I have a Department entity which relations are as follows:
Many departments can be in one parent department:
You'll have to set the children's ik_parent_department_id
to null explicitly.
Department parentDepartment = (Department) session.load(Department.class, id);
session.delete(parentDepartment);
for (Department child : parentDepartment.getChildren()){
child.setParentDepartment(null);
}
session.flush();
With cascading you would only manage to delete child Departments
.