1 Reply Latest reply on Aug 3, 2006 1:01 PM by c_eric_ray

    Can't get DELETE_ORPHAN to work with java.persistence.Cascad

      I need to annotate a OneToMany relationship like so...

      @OneToMany(mappedBy="remittancePackage", cascade= {CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
      

      However, this does not compile becuse the "cascade" parameter is of type java.persitence.CascadeType. How do I do this?

      I need this behavior...

      If the child object's lifespan is bounded by the lifespan of the parent object, make the parent a full lifecycle object by specifying CascadeType.ALL and org.hibernate.annotations.CascadeType.DELETE_ORPHAN (please refer to the Hibernate reference guide for the semantics of orphan delete)


      And yes, I've read the Hibernate docs. Good for reference but doesn't tell you how to do this in EJB3 with annotations.

      Thanks.
      Eric Ray

        • 1. Re: Can't get DELETE_ORPHAN to work with java.persistence.Ca

          the answer is...

          @OneToMany(mappedBy="remittancePackage", cascade=CascadeType.ALL)
          @Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
          


          where @Cascade os a hibernate Cascade object.

          Would be nice if these hints were in the documention. It really helps those of use who are not experienced with hibernate.

          Thanks
          Eric Ray