2 Replies Latest reply on Jul 1, 2011 3:07 PM by pv

    Hibernate Reverse Engineering JPA orphanRemoval

    pv

      Looks like hibernate reverse engineering currently does not support JPA orphan removal. Is there a way to set the JPA orphanRemoval attribute through a custom reverse engineering strategy or by modifying the freemarker templates.

        • 1. Re: Hibernate Reverse Engineering JPA orphanRemoval
          dgeraskov

          Sure you can do this. Look at Ejb3PropertyGetAnnotation.ftl.

          For example ${pojo.generateOneToOneAnnotation(property, cfg)}

          This will create @OneToOne annotation. If you use JPA2.0 specification you can alter returned string with orphanRemoval="true" attribute. (By using String#substring and concatenation).

          In JPA1.0 you can just add

          @org.hibernate.annotations.Cascade( value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN)

          after the generated @OneToOne.

           

          Hope this helps

          • 2. Re: Hibernate Reverse Engineering JPA orphanRemoval
            pv

            Is there a way to do this selectively based on a meta attribute?