我使用 Hibernate 自动生成我的数据库进行测试,并且我的架构中有一些表包含需要很长时间才能导入的静态数据。过去,我在构建文件中使用以下代码生成数据库(从映射文件):
<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 文件是使用 XDoclet 生成的。我正在迁移到使用 Hibernate Annotations 进行映射,所以我正在使用 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 一样。任何人都知道是否有办法这样做?