带有休眠注释的模式导出 [英] Schema export with hibernate annotations

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

问题描述

我正在使用休眠注释并且我想导出我的数据库架构.

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 Core SchemaExportTask 只能处理 Hibernate XML 映射文件,不能处理注解.您需要的是 Hibernate Tools 附带的 HibernateToolTask​​.

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 Persistence With 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 Annotations &蚂蚁
  • 这篇关于带有休眠注释的模式导出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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