我最近原来的数据库丢失 所以用了hbm2dll 把它恢复了 但是临时的测试数据没了
简单说一下 供大家参考
我用的是 hibernate3.jar
把build.xml贴出来 大家参考
<?xml version="1.0" encoding="utf-8"?>
<project name="AutoGen" default="make-schema" basedir=".">
<!-- 源文件目录定义 -->
<property name="src.dir" value="./src" />
<!-- 配置目录 -->
<property name="conf.dir" value="./com/tourist/db" />
<!-- 自动生成目录 -->
<property name="class.dir" value="./WebRoot/WEB-INF/classes" />
<!-- class文件输出目录 -->
<property name="gen.dir" value="./gen" />
<!-- 库文件目录 -->
<property name="lib.dir" value="./WebRoot/WEB-INF/lib" />
<!-- 类路径 -->
<path id="build-classpath">
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
<pathelement location="${class.dir}" />
</path>
<!-- 功能实现1:自动生成数据库表及sql -->
<target name="make-schema">
<!-- 定义task -->
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask">
<classpath refid="build-classpath" />
</taskdef>
<taskdef name="annotationconfiguration"
classname="org.hibernate.tool.ant.AnnotationConfigurationTask">
<classpath refid="build-classpath" />
</taskdef>
<!-- 生成DDL -->
<hibernatetool destdir="${gen.dir}">
<classpath refid="build-classpath" />
<configuration
configurationfile="hibernate.cfg.xml">
</configuration>
<hbm2ddl export="false" drop="false" create="true"
delimiter=";" outputfilename="schema.sql" destdir="${gen.dir}" />
</hibernatetool>
</target>
</project>
org.hibernate.tool.ant.HibernateToolTask。该类不在hibernate3.jar中,而在hibernate-tools.jar文件中。执行该任务需要用到的类包括:
hibernate3.jar
hibernate-tools.jar
jtidy-r8-21122004.jar
velocity-1.4.jar
velocity-tools-generic-1.1.jar