开发者

Using hbm2ddl when model and EM are in different projects

I have a locally-created jar file containing hibernate-annotated entities. I also have a separate project which references this jar.

I need to create a db script using hbm2ddl, but am encounting some difficulty. When开发者_Go百科 I try to use the task in the jar file's build.xml, the persistence unit can't be found. When I try to use the task in the war file's build.xml, no entities are found at all.

This has to be something that's being done by others -- how do you create the SQL when the entities and EM are in different Eclipse projects built by separate build scripts?


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜