【问题标题】:Using hbm2ddl when model and EM are in different projects当模型和 EM 在不同的项目中时使用 hbm2ddl
【发布时间】:2011-06-29 19:24:47
【问题描述】:

我有一个本地创建的 jar 文件,其中包含带有 hibernate 注释的实体。我还有一个单独的项目引用了这个 jar。

我需要使用 hbm2ddl 创建一个 db 脚本,但遇到了一些困难。当我尝试使用 jar 文件的 build.xml 中的任务时,找不到持久性单元。当我尝试使用 war 文件的 build.xml 中的任务时,根本找不到任何实体。

这必须是其他人正在做的事情——当实体和 EM 位于由单独的构建脚本构建的不同 Eclipse 项目中时,您如何创建 SQL?

【问题讨论】:

    标签: hibernate hbm2ddl


    【解决方案1】:

    这里的技巧是在包含 hbm2ddl 的任务的类路径中包含 jar 文件:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-04
      • 2012-07-21
      • 1970-01-01
      相关资源
      最近更新 更多