4 Replies Latest reply on Jul 11, 2008 11:16 PM by luxspes

    seam-gen overwritting

    alderion

      hi, i'm brand new to seam and have been playing around with seam-gen.  i wonder why seam-gen doesn't support some sort of class hierarchy so that custom code can be added without it being overwritten by the next generation.


      say i have a user entity with an email column that i want validated.  i would think that i would add the @Email annotation above my getter but if i ever need to regen the user entity my edit will be overwritten.  how do people work around this issue?


      thanks,


      -peter

        • 1. Re: seam-gen overwritting
          andygibson.contact.andygibson.net

          I think people only really use the Seam-Gen stuff to get started, I don't think it is meant as a continuous two way tool between the database and the model/view.


          Cheers,


          Andy Gibson

          • 2. Re: seam-gen overwritting

            Hi!



            Andy Gibson wrote on Jul 11, 2008 20:23:


            I think people only really use the Seam-Gen stuff to get started, I don't think it is meant as a continuous two way tool between the database and the model/view.

            Cheers,

            Andy Gibson


            Well, in my team we are trying to reshape it in to a continuous two way tool between the database and the model/view, but it is harder job than I though because the documentation on how to enhance JbossTools is... well, lets just say that is not.


            Regards,

            • 3. Re: seam-gen overwritting
              taccart.thierry.accart.name

              Hi


              in fact, the document is there, but another there than where you're looking for ;-)


              The reverse engineering and POJO code generation are  documented on hibernate web site.
              If you have a look in seam-gen sub folders, you'll find all freemaker templates (.flt files) used.


              They could give you ideas for implementations of your needs.
              For instance, you could modify the flt template files for entities generation to add custom toString() ala commonclipse generated ones, or template of xxxxEdit.xhtml pages to use RichFaces listShuttle in many to many / manyToOne / oneToMany relations...



              Having a permanent generation of code, IMHO, is relevant that your DB has not been designed correctly. Of course, your needs cab change and your schema can change, but most of time it affects one or two tables.
              In this case, the simplest solution is to run seam-gen on a distinct project and run a compare between seamgen generated project and developers project.


              You should consider also this hibernate article on Equals and HashCode before going for a constant generation of code.


              I wish this will help :-)


              Rgds

              • 4. Re: seam-gen overwritting

                Hi!



                thierry accart wrote on Jul 11, 2008 22:47:


                Hi

                in fact, the document is there, but another there than where you're looking for ;-)

                The reverse engineering and POJO code generation are  documented on hibernate web site.
                If you have a look in seam-gen sub folders, you'll find all freemaker templates (.flt files) used.


                Been there, read that, done that, it is good for the basics, but it is insufficient just try to find the answer to this question in there.



                They could give you ideas for implementations of your needs.
                For instance, you could modify the flt template files for entities generation to add custom toString() ala commonclipse generated ones, or template of xxxxEdit.xhtml pages to use RichFaces listShuttle in many to many / manyToOne / oneToMany relations...


                Again been there, done that. :-)



                Having a permanent generation of code, IMHO, is relevant that your DB has not been designed correctly. Of course, your needs cab change and your schema can change, but most of time it affects one or two tables.


                Sadly, in my experience, requirement changes from customers affect a lot more than two tables...



                In this case, the simplest solution is to run seam-gen on a distinct project and run a compare between seamgen generated project and developers project.


                Or, if I could find an answer to  that question, generation could be easily controlled using annotations... Or you could use Ant.. but I really prefer Eclipse (yes, I think I may be crazy)



                You should consider also this hibernate article on Equals and HashCode before going for a constant generation of code.

                I wish this will help :-)

                Rgds


                Read that too... but I can not see a direct relationship between that and code generation


                Regards,