0 Replies Latest reply on May 25, 2006 3:30 PM by allan bronson

    Cannot delete child in oneToMany association

    allan bronson Newbie

      I have a class that is the parent to 2 other sets of objects.

      In my parent class I use this code to set up the relationship:

      @OneToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
      set ChildOne

      @OneToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
      set ChildTwo

      In my SessionBean I get an exception saying child found when I make this call.

      em.remove( parent );

      My Bean will insert and update correctly( add the children or update their values ) but will not delete.

      I know in hiberante they had a cascade=all-delete-orphan value. Is there anything similar to this?

      I also tried to another way and got another exception.

      1 Get parent to delete
      2 Loop thru set of children and delete them one at a time
      3 delete parent



      Thanks,

      abronson