0 Replies Latest reply on Aug 31, 2007 8:37 AM by ajeethkiran

    hibernate - on delete parent, cascadetype to set NULL for ch

    ajeethkiran

      hello everyone,

      I am searching for a way out to set NULL for the child upon deletion of the parent using hibernate annotations. Can some one please guide me on this? The annotation used presently in Table1.java is shown below and CascadeType.ALL doesn't even prevent the child from being deleted when the parent is deleted (as claimed in the page 10 of http://www.laliluna.de/download/ejb3-struts-tutorial-en.pdf).

      @OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.EAGER, mappedBy="table1", targetEntity=Table2.class)
      public Set getTable2s() {
       return this.table2s;
      }


      By using the following block in Table1.hbm.xml, it is working the desired way. That is, it sets the child as NULL when the parent is deleted.

      <set name="table2s" cascade="none" lazy="true">
       <key column="link2one" />
       <one-to-many class=".Table2" />
      </set>


      Is there an equivalent for the same in EJB3 annotations?

      Thank you,
      Ajeeth Kiran