本文介绍了出口模式与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的注释和放大器;蚂蚁
- Hibernate 3 Annotations & Ant
See also
更多推荐
出口模式与Hibernate的注解
发布评论