题
我有一个包含hibernate annotation实体的本地创建的jar文件。我还有一个单独的项目,它引用这个jar。
我需要使用HBM2DDL创建一个DB脚本,但是正在收到一些难度。当我尝试在JAR文件的Build.xml中使用任务时,找不到持久性单元。当我尝试在War File的Build.xml中使用任务时,根本没有找到实体。
这必须是别人所做的事情 - 当实体和EM在不同的构建脚本构建的不同Eclipse项目中,您如何创建SQL?
解决方案
The trick here was including the jar file in the classpath of the task which includes hbm2ddl:
<target name="schemaexport" depends="compile">
<hibernatetool destdir="${basedir}/sql">
<classpath>
<fileset dir="${lib.dir}">
<include name="common.jar" />
</fileset>
</classpath>
<jpaconfiguration />
<hbm2ddl export="false" create="true" drop="true" delimiter=";" format="true" outputfilename="${project.name}-ddl.sql" />
</hibernatetool>
</target>
不隶属于 StackOverflow