5 Replies Latest reply on Sep 21, 2006 3:48 PM by epbernard

    How to cause related entities to update when base entity is

    a_titov82

      I have two entities:

      public class Employee {
      ...
       @ManyToOne
       public Organization getPlaceOfWork() {
       return placeOfWork;
       }
       public void setPlaceOfWork(Organization placeOfWork) {
       this.placeOfWork = placeOfWork;
       if(placeOfWork!=null){
       placeOfWork.getEmployees().add(this);
       }
       }
      
      }
      
      public class Organization {
      ...
       @OneToMany(fetch=FetchType.EAGER, mappedBy="placeOfWork")
       public Collection<Employee> getEmployees() {
       return employees;
       }
       public void setEmployees(Collection<Employee> employees) {
       this.employees = employees;
       }
      }

      How can I cause Employees to be set their placeOfWork to null when Organization is removed (like database cascade)? And what should I do, if I want to delete Employees when Organization is removed?