具有休眠注释的架构导出

安东尼:

我正在使用休眠注释,并且想导出数据库模式。

类似于带有hbm xml文件的schemaexporttask。

Pascal Thivent:

实际上,原始的Hibernate Core SchemaExportTask只能处理Hibernate XML映射文件,而不能处理注释。您需要的是Hibernate ToolsHibernateToolTask附带的工具

这是一个改编自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>

也可以看看

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章