3 Replies Latest reply on Feb 16, 2006 5:01 AM by epbernard

    Cascade Delete on 3 Entities not working

    ppc

      I've 3 Entities

      A have a @OneToMany (cascade = CascadeType.ALL,...) with B
      B have a @OneToMany (cascade = CascadeType.ALL,...) with C

      If I create A and B
      then i can delete A (B is also deleted)

      if I create B and C
      then I delete B (C is also deleted)

      but:

      if I Create A, B and C
      then
      I got and org.hibernate.exception.ConstraintViolationException on B
      when I try to delete A

      in the logs seam that hibernate is not considering that B has also a cascade delete.

        • 1. Re: Cascade Delete on 3 Entities not working
          epbernard

          That 's most likely something else. The example you describe works

          • 2. Re: Cascade Delete on 3 Entities not working
            nholbrook

            I've got a similar issue.
            For some odd reason, if I use a detached object and pass it back to the server to delete the object, it works fine. If I just pass the id of the object and have the server do a lookup then remove on the object, I get the same errors you are describing.

            ---------------------------------- Works ---------------------

            Detached Client

            Company company = proxy.findMyCompany();
            proxy.delete(company)

            Server

            persistenceManager.remove(company);

            --------------------------------------------- Doesn't work --------------------------------------

            Detached Client

            proxy.deleteCompany(companyId);

            Server

            Company company = persistenceManager.find(compan);
            persistenceManager.remove(company);

            • 3. Re: Cascade Delete on 3 Entities not working
              epbernard

              I find it hard to believe