3 Replies Latest reply on Nov 5, 2006 10:03 AM by maxandersen

    Generating EJB 3 with life-cycle methods using hibernate

    a_titov82

      Hello. I can use hibernate plug-in to generate EJB 3 Entities from POJOs. But is there any way to define methods that should be copied from POJO to Entity (without change) and methods, that should be copied from POJO to Entity and marked as lifecycle methods (@PreRemove, @PostRemome, etc.).

        • 1. Re: Generating EJB 3 with life-cycle methods using hibernate
          maxandersen

          huh!?

          • 2. Re: Generating EJB 3 with life-cycle methods using hibernate
            a_titov82

            :-(

            "Hibernate code generation" can transform MyClass...

            public class MyClass {
             private String name;
             public String getName() {
             return name;
             }
             public void setName(String name) {
             this.name = name;
             }
            }
            

            to this...
            public class MyClass {
             private String name;
             @Column(name = "name", unique = false, nullable = true, insertable = true, updatable = true)
             public String getName() {
             return this.name;
             }
            
             public void setName(String name) {
             this.name = name;
             }
            }
            

            That is good.
            But can it transform MyClass2...
            public class MyClass2 {
             private String name;
             public String getName() {
             return name;
             }
             public void setName(String name) {
             this.name = name;
             }
             
             public void myMethod(){
             //do some action...
             }
            
            }
            

            to this...
            public class MyClass2 {
             private String name;
             @Column(name = "name", unique = false, nullable = true, insertable = true, updatable = true)
             public String getName() {
             return this.name;
             }
            
             public void setName(String name) {
             this.name = name;
             }
             
             @PreUpdate
             public void myMethod(){
             //do some action...
             }
            
            }
            

            ?

            • 3. Re: Generating EJB 3 with life-cycle methods using hibernate
              maxandersen

              well not really since it does code *generation* not code *transformation*.

              but do note you can always use the meta tags or simply customize the templates to makeit do what you want.