无法使用hibernate3-maven-plugin-3.0生成hbm2ddl [英] Unable to generate hbm2ddl using hibernate3-maven-plugin-3.0

查看:235
本文介绍了无法使用hibernate3-maven-plugin-3.0生成hbm2ddl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已更新到更新版本的hibernate3-maven-plugin。

I have updated to a newer version of hibernate3-maven-plugin. I get the following error trying to use the plugin mentioned below.

希望能解决这个问题的任何指针。

Would appreciate any pointers in resolving this issue.

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>hibernate3-maven-plugin</artifactId>
    <version>3.0</version>

    <executions>
        <execution>
            <id>create sql schema</id>
            <phase>process-test-resources</phase>
            <goals>
                <goal>hbm2ddl</goal>
            </goals>
            <configuration>
                <componentProperties>
                    <persistenceunit>${app.module}</persistenceunit>
                    <drop>false</drop>
                    <create>true</create>
                    <outputfilename>${app.sql}-create.sql</outputfilename>
                    <skip>${db.schema.gen.skip}</skip>
                </componentProperties>
            </configuration>
        </execution>

        <execution>
            <id>drop sql schema</id>
            <phase>process-test-resources</phase>
            <goals>
                <goal>hbm2ddl</goal>
            </goals>
            <configuration>
                <componentProperties>
                    <persistenceunit>${app.module}</persistenceunit>
                    <drop>true</drop>
                    <create>false</create>
                    <outputfilename>${app.sql}-drop.sql</outputfilename>
                    <skip>${db.schema.gen.skip}</skip>
                </componentProperties>
            </configuration>
        </execution>
    </executions>
</plugin>

[ERROR] Failed to execute goal org.codehaus.mojo:hibernate3-maven-plugin:3.0:hbm2ddl (create sql schema) on project sample: There was an error creating the AntRun task. NullPointerException -> [Help 1]org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:hibernate3-maven-plugin:3.0:hbm2ddl (create sql schema) on project framework: There was an error creating the AntRun task.


推荐答案

配置方式改为直接使用蚂蚁休眠工具插件。因此,配置与蚂蚁插件完全相同,而不需要额外的taskDef。 jpaconfiguration。请参阅hibernate ant工具参考文档: http: //docs.jboss.org/tools/3.3.0.Final/en/hibernatetools/html_single/index.html#d0e4651 获取更多信息。

The way of configuration changed to direct usage of the ant hibernate tool plugin. So the configuration is exactly the same format like the ant plugin without the need of additional taskDef for e.g. jpaconfiguration. See hibernate ant tool references documentation: http://docs.jboss.org/tools/3.3.0.Final/en/hibernatetools/html_single/index.html#d0e4651 for more information.

对于具有jpa配置的hbm2ddl,您可以使用以下内容:

For a hbm2ddl with a jpa configuration you could use the following:

<plugin>
    <!-- run "mvn hibernate3:hbm2ddl" to generate a schema -->
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>hibernate3-maven-plugin</artifactId>
    <version>3.0</version>

    <configuration>
        <hibernatetool>
            <jpaconfiguration persistenceunit="unitname" />

            <hbm2ddl export="false" create="true"
                update="true" format="true" outputfilename="schemaDiff.ddl" />

        </hibernatetool>
    </configuration>
</plugin>

失败有target / antrun / build-main。 xml文件来配置hibernate工具。对于上面的例子,这看起来如下所示:

On failures there is the "target/antrun/build-main.xml" file which configures the hibernate tools. For the above example this looks like following:

<?xml version="1.0" encoding="UTF-8" ?>
<project name="maven-antrun-" default="main"  >
<target name="main">
  <taskdef classname="org.hibernate.tool.ant.EnversHibernateToolTask" name="hibernatetool"/>
  <mkdir dir="/home/xxx/workspace/projectname/target/sql/hibernate3"/>
  <hibernatetool destdir="/home/xxx/workspace/projectname/target/sql/hibernate3">
    <jpaconfiguration persistenceunit="schemaDiff"/>
    <hbm2ddl update="true" export="false" outputfilename="schemaDiff.ddl" format=
"true" create="true"/>
  </hibernatetool>
</target>
</project>

这篇关于无法使用hibernate3-maven-plugin-3.0生成hbm2ddl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆