hbm2dll小例子

我最近原来的数据库丢失 所以用了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 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值