出口模式与Hibernate的注解 [英] Schema export with hibernate annotations

查看:193
本文介绍了出口模式与Hibernate的注解的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Hibernate注解,我想导出我的数据库架构。

I'm using hibernate annotations and i want to export my database schema.

与HBM XML文件schemaexporttask类似。

Similar to the schemaexporttask with hbm xml files.

推荐答案

事实上,原来的Hibernate核心 SchemaExportTask 只能处理Hibernate XML映射文件,没有注释。你需要的是 HibernateToolTask​​ Hibernate的工具的。

Indeed, the original Hibernate Core SchemaExportTask can only handle Hibernate XML mapping files, not annotations. What you need is the HibernateToolTask that comes with Hibernate Tools.

下面是一个使用示例改编自Java持久性使用Hibernate:

Here is an Usage example adapted from Java Persistence With Hibernate:

<taskdef name="hibernatetool"
         classname="org.hibernate.tool.ant.HibernateToolTask"
         classpathref="project.classpath"/>
  <target name="schemaexport" depends="compile, copymetafiles"
          description="Exports a generated schema to DB and file">
    <hibernatetool destdir="${basedir}">
      <classpath path="${build.dir}"/>
      <configuration 
          configurationfile="${build.dir}/hibernate.cfg.xml"/>
      <hbm2ddl
          drop="true"
          create="true"
          export="true"
          outputfilename="helloworld-ddl.sql"
          delimiter=";"
          format="true"/>
    </hibernatetool>
</target>

另请参见


  • Hibernate 3的注释和放大器;蚂蚁

  • See also

    • Hibernate 3 Annotations & Ant
    • 这篇关于出口模式与Hibernate的注解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆