모델 및 EM이 다른 프로젝트에있을 때 HBM2DDL 사용
문제
Hibernate-agnotated 엔티티가 포함 된 로컬로 만든 JAR 파일이 있습니다.또한이 JAR을 참조하는 별도의 프로젝트가 있습니다.
HBM2DDL을 사용하여 DB 스크립트를 만들어야하지만 몇 가지 어려움을냅니다.JAR 파일의 build.xml에서 작업을 사용하려고하면 지속성 단위를 찾을 수 없습니다.WAR 파일의 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