1. 開發順序
top-down:POJO-(XDoclet)-hbm-(hbm2ddl)-schema
bottom-up:schema-(MiddleGen)-hbm-(hbm2java)-POJO
中間開花:hbm2ddl hbm2java
2. hbm2ddl hbm2java的實現方法
<project name="hibernate" default="schemaexport" basedir=".">
<path id="libraries">
<fileset dir="./lib">
<include name="*.jar" />
</fileset>
</path>
<target name="schemaexport">
<taskdef name="schemaexport"
classname="org.hibernate.tool.hbm2ddl.SchemaExportTask"
classpathref="libraries"/>
<schemaexport properties="./hibernate.properties"
quiet="no"
text="no" drop="no"
delimiter=";"
output="./schema/schema-export.sql">
<fileset dir="hbm">
<include name="**/*.hbm.xml"/>
</fileset>
</schemaexport>
</target>
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="libraries"/>
<target name="codegen" >
<hibernatetool destdir="java">
<configuration>
<fileset dir="hbm">
<include name="**/*.hbm.xml"/>
</fileset>
</configuration>
<hbm2java/>
</hibernatetool>
</target>
</project>
2. hbm2ddl須要注意
使用hibernate.properties,使用hibernate.cfg.xml報找不到hbm.xml的錯誤,沒有解決
直接使用3.2.7ga.jar就行
3. hbm2java須要注意
須要HibernateTools-3.2.0.beta9a.zip中的hibernate-tools.jar freemarker.jar
http://sourceforge.net/projects/hibernate/files/hibernate3/3.2.6.ga/hibernate-3.2.6.ga.zip/download?_test=nocounterjava