lauvigne wrote:
Il te faut récupérer hibernate tools
HibernateTools-3.1.0.beta1.zip
les jars necessaires sont ceux d'hibernate + ceux dse tools dans plugins\org.hibernate.eclipse_3.1.0.beta1
pour partir uniquement des HBM et générer le ddl et les POJO/DAO et docs, il est necessaire que tes HBM soient complets avec les types définis pour chaque propriétés/colonnes...
ensuite, le + simple est un script ant du style :
Code:
<project name="generation" default="usage" basedir="." >
<property name="project-dir" value="${basedir}/.."/>
<property name="source-dir" value="${project-dir}/src/java"/>
<property name="lib-dir" value="${project-dir}/lib"/>
<property name="target-dir" value="${basedir}/target"/>
<path id="classpath">
<fileset dir="${lib-dir}">
<include name="**/*.jar"/>
</fileset>
</path>
<target name="usage">
<!-- echoproperties/ -->
<echo>
------------- usage --------------
* clean suppression du repertoire cible de geénération
* all lance hbm2ddl,hbm2java,hbm2doc
* hbm2ddl schemaexport, exports and/or executes the SQL DDL for the configuration to the database
* hbm2java codegenerator, generates a set of .java files
* hbm2doc generates html documentation for the database schema et.al.
----------------------------------
</echo>
</target>
<target name="clean" description="suppression du repertoire cible de geénération" >
<delete dir="${target-dir}"/>
<mkdir dir="${target-dir}"/>
</target>
<target name="all" depends="clean" description="lance toutes les générations" >
<antcall target="hbm2ddl" />
<antcall target="hbm2java" />
<antcall target="hbm2dao" />
<antcall target="hbm2doc" />
</target>
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="classpath" />
<target name="hbm2ddl" description="creation du schema sql">
<hibernatetool destdir="${target-dir}">
<configuration propertyFile="hibernate.properties" > <!-- configurationfile="hibernate.cfg.xml" -->
<fileset dir="${source-dir}" id="id">
<include name="**/*.hbm.xml"/>
</fileset>
</configuration>
<!--
export Export schema DDL to the database No, default: true
console Print schema DDL to the console No, default: true
update Update instead of create schema No, default: false
drop Issue drop statements No, default: false
create Issue create statements No, default: true
outputfilename file to dump schema DDL to. Relative to destdir No, default: empty
delimeter delimiter to use when sending to file No, default: ';'
-->
<hbm2ddl export="false" console="true" drop="false" outputfilename="schema-export.sql" />
</hibernatetool>
</target>
<target name="hbm2doc" description="création docs model et tables">
<hibernatetool destdir="${target-dir}/doc">
<configuration propertyFile="hibernate.properties" >
<fileset dir="${source-dir}" id="id">
<include name="**/*.hbm.xml"/>
</fileset>
</configuration>
<hbm2doc templatepath="custom/doc" />
</hibernatetool>
</target>
<target name="hbm2java" description="generation des pojo">
<hibernatetool>
<configuration propertyFile="hibernate.properties" >
<fileset dir="${source-dir}" id="id">
<include name="**/*.hbm.xml"/>
</fileset>
</configuration>
<hbm2java destdir="${target-dir}/POJO" />
</hibernatetool>
</target>
<target name="hbm2dao" description="generation des dao">
<hibernatetool>
<configuration propertyFile="hibernate.properties" >
<fileset dir="${source-dir}" id="id">
<include name="**/*.hbm.xml"/>
</fileset>
</configuration>
<hbm2dao destdir="${target-dir}/DAO" />
</hibernatetool>
</target>
</project>
avec un hibernate.properties du genre :
Code:
hibernate.dialect=org.hibernate.dialect.Oracle9Dialect
hibernate.connection.password=sa
hibernate.connection.username=sa
hibernate.connection.url=jdbc:oracle:thin:@monserveur:1521:mabase
hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver
hibernate.default_schema=sa