9 Replies Latest reply on Mar 2, 2006 1:33 PM by eracer

    DefaultReverseEngineeringStrategy

    eracer

      Hi,

      ----
      How to reverse engineer from the hbm to the java files ?
      ----

      I am trying to produce java code from my database. Thanks for the post about the DefaultReverseEngineeringStrategy, because I had the same bug as explained here http://www.jboss.com/index.html?module=bb&op=viewtopic&t=74849

      Anyway, now I have the Java classes, but I need to change the
      generator class="assigned" to generator class="increment" within the hbm files.

      Then I need to generate the Java again from the modified hbm files, without going back from the database anymore! How shall I do that ? Is there some undocumented feature to use instead of DefaultReverseEngineeringStrategy ?

      Etienne

        • 1. Re: DefaultReverseEngineeringStrategy
          maxandersen

          beta4 does not have the need for you to specify the reverse engineerings strategy.

          if you want to change the generator strategy for *all* table/classes then the simplest thing is to implement a custom strategy that return "increment" in the getTableIdentifierStrategyName.

          Your last question is a bit ambigious ? Are you asking how to generate code from existing mapping files ? Simply *don't* select to reverse engineer then it will take the current mappings and use for its code generation.

          /max

          • 2. Re: DefaultReverseEngineeringStrategy
            eracer

            Hi Max,

            Thanks for your prompt reply.

            I have changed the generators type in the mapping files by hand, then run the code generation again, but with "reverse engineering from JDBC connection" unchecked. I thought this as what you meant.
            I get an error saying that it does find the xx.hbm.xml files, and they are there.
            Also, the package name does not look to be taken into account when producing the Java files.

            Etienne

            • 3. Re: DefaultReverseEngineeringStrategy
              eracer

              I expect the id to be removed from the full and minimal constructors.
              I can remove them by hand as well.

              • 4. Re: DefaultReverseEngineeringStrategy
                maxandersen

                are the mapping file available through the classpath of the console configuration ?

                • 5. Re: DefaultReverseEngineeringStrategy
                  eracer

                  Brilliant, this is it. I confirm that the id are not in the constructors anymore if the generator is set to 'increment'.

                  I also confirm that the package does not work for me. The JBoss Hibernate tool creates the java files in the default package, and if I move them to another package then I get an error from Hibernate at run time for classes created for composite keys, saying he does not find the hbm file for them. Of course they are no such files.

                  Etienne

                  I will t

                  • 6. Re: DefaultReverseEngineeringStrategy
                    maxandersen

                    ...and your revengstrategy is set to blank ?


                    ...and if you have a custom revengstrategy it implements DelegateReverseEngineringStrategy so it does not "swallow" the table to package/classname calls ?

                    • 7. Re: DefaultReverseEngineeringStrategy
                      eracer


                      >> ...and your revengstrategy is set to blank ?

                      To do this, I have to check the reverse engineering checkbox, and I get an ClassNotFoundException (mentioned in the link given in my first message).
                      So I read that I need to use this value org.hibernate.cfg.reveng.DefaultReverseEngineeringStrategy, but the package is not generated.

                      >> ...and if you have a custom revengstrategy it implements DelegateReverseEngineringStrategy so it does not "swallow" the table to package/classname calls ?

                      I don't know how to do that. Probably I would need to dip into your source code for a few days before being efficient. Is this what you mean ?

                      • 8. Re: DefaultReverseEngineeringStrategy
                        maxandersen


                        you need to upgrade to beta4 which does not require this reveng strategy.

                        (and the part of how to write a revengstrategy is documented in the docs)

                        • 9. Re: DefaultReverseEngineeringStrategy
                          eracer

                          Max,

                          It's all ok with beta 4. The package is generated properly, the mapping file is correct regarding the package and it runs smoothly.

                          I will re-generate the Java files after changing manually the generator in the mapping files, this is absolutely fine.

                          Thanks very much for your support, especially that the code is right, I did not figure out that this functionality was so much on the edge and beta 3 was contained in the bundle.

                          I think I will become a big fan of JBoss, and look forward to using the Seam product in a few months.

                          Etienne