1 Reply Latest reply on Feb 12, 2010 5:55 PM by Rafael Ribeiro

    Configure seam-gen to use hbm.xml instead of annotated classes

    Rafael Ribeiro Novice

      Hi all,


      Is there any way I could configure Seam-Gen to generate hbm.xml files instead of annotated classes?
      I've searched over google but I could only find this page.
      The reason I am trying to do this is to enable me to use the database comments (that are unsupported for annotations) inside freemarker templates. I am willing to use column comments as field labels on the generated edit pages ftl templates.


      best regards,
      Rafael Ribeiro

        • 1. Re: Configure seam-gen to use hbm.xml instead of annotated classes
          Rafael Ribeiro Novice

          We were able to figure out after a few more attempts.
          Locate the following code on seam-gen\build.xml


          <target name="generate-model" depends="validate-project,init-generate">
                  <echo message="Reverse engineering database using JDBC driver ${driver.jar}"/>
                  <echo>project=${project.home}</echo>
                  <echo>model=${model.package}</echo>
                  <hibernate templatepath="${templates.dir}">
                      <jdbcconfiguration propertyfile="${seam-gen.properties}"
                                          packagename="${model.package}"
                                           revengfile="${project.home}/resources/seam-gen.reveng.xml"
                                     detectmanytomany="false"/>
          
                      <property key="hibernatetool.util.toolclass"
                              value="org.jboss.seam.tool.Util"/>
                      <hbm2hbmxml destdir="${project.home}/src/main"/>
                      <hbm2java jdk5="true" ejb3="false" destdir="${project.home}/src/main"/>
                  </hibernate>
          
                  <taskdef name="javaformatter"
                       classname="org.hibernate.tool.ant.JavaFormatterTask" classpathref="htools.classpath"/>
          
                  <javaformatter>
                    <fileset dir="${project.home}/src/main">
                            <include name="**/*.java"/>
                    </fileset>
                  </javaformatter>
          
              </target>




          The example above is already changed to output hbm.xml files, the changes are:




          • Setting ejb3=false

          • And adding the tag hbm2hbmxml



          In summary... the most relevant lines are


                     <hbm2hbmxml destdir="${project.home}/src/main"/>
                      <hbm2java jdk5="true" ejb3="false" destdir="${project.home}/src/main"/>