1 Reply Latest reply on Nov 30, 2006 7:30 PM by Gavin King

    Bidirectional OneToMany removal of related entities

    ngeadah Newbie

      If I have a bidirectional OneToMany and I remove a related entity from the Set, then call "persist", is the removed related entity supposed to get deleted from the database or not? In my case it is not getting deleted, altough I was under the impression that persist would reflect all changes made to the object graph (my cascade is "ALL"). The removal from the Set is definitely occuring - it's just not getting reflected in the DB.

      some code to explain:

      Parent:

      @OneToMany(mappedBy="form", cascade=CascadeType.ALL, fetch=FetchType.EAGER)
      public Set<BaseSchedule> getSchedules()
      {
      return schedules;
      }
      


      Child:

      @ManyToOne
      public BaseForm getForm()
      {
      return form;
      }
      


      Removal code:

      
      form.getSchedules().remove(someSchedule);
      em.persist(form); // This is NOT deleting the child