我使用Hibernate自动生成我的数据库进行测试,并且我的模式中有一些表包含需要很长时间导入的静态数据。在过去,我用下面的代码在我的构建文件生成数据库(从映射文件):使用了XDoclet生成有没有办法让Hibernate的hbm2ddl Ant任务排除特定的表?
<target name="schema-gen" depends="hibernate-gen">
<taskdef name="schemaexport" classname="org.hibernate.tool.hbm2ddl.SchemaExportTask" classpathref="project.classpath" />
<schemaexport properties="resources/hibernate.properties" text="false" quiet="false" delimiter=";" output="schema.sql">
<fileset dir="${build.doclets}">
<include name="**/*.hbm.xml" />
<exclude name="**/inert/*.hbm.xml" />
</fileset>
</schemaexport>
</target>
的的.hbm.xml文件。我迁移到使用Hibernate注解映射,所以我搬到hibernatetools生成模式:
<target name="annotations-export" depends="hibernate-gen">
<hibernatetool destdir="${basedir}">
<annotationconfiguration configurationfile="${basedir}/resources/hibernate.cfg.xml" propertyfile="${basedir}/resources/hibernate.properties" />
<classpath>
<path refid="project.classpath" />
</classpath>
<hbm2ddl drop="true" create="true" export="true" outputfilename="schema.sql" delimiter=";" format="true" />
</hibernatetool>
</target>
我希望能够告诉先得用hbm2ddl的“惰性”离开了班包,就像我以前用schemaexport一样。任何人都知道是否有办法做到这一点?
这不是我要找的。我想重新创建大多数表格(为我的测试重置事物),但我想跳过一些表格。更新会使所有存在的东西都完好无损,这并不是我想要的行为。 – Rafe 2010-01-26 21:54:21