如何使用org.hibernate.tool.EnversSchemaGenerator生成Envers数据库架构? [英] How to generate Envers database schema with org.hibernate.tool.EnversSchemaGenerator?

查看:83
本文介绍了如何使用org.hibernate.tool.EnversSchemaGenerator生成Envers数据库架构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Hibernate更新为4.1.1.Final版本.根据文档 有两种生成数据库模式的方法:

I updated Hibernate to the 4.1.1.Final version. According to the documentation There are 2 ways to generate a database schema:

  1. 蚂蚁任务org.hibernate.tool.ant.EnversHibernateToolTask.
  2. 从Java运行org.hibernate.tool.EnversSchemaGenerator.
  1. Ant task org.hibernate.tool.ant.EnversHibernateToolTask.
  2. Run org.hibernate.tool.EnversSchemaGenerator from Java.

Hibernate-tools不适用于Hibernate-4.1.1.Final.它具有阻止错误.

Hibernate-tools doesn't work with Hibernate-4.1.1.Final. It has a blocking bug.

我仅找到发行说明和一个

I found only release notes and a test case. So how can I use org.hibernate.tool.EnversSchemaGenerator with my persistence.xml and Maven?

更新:

在Hibernate论坛上找到相关的线程.看来我的问题还没有答案.

Found related thread on the Hibernate forum. It seems there is no answer to my question yet.

推荐答案

Juplo已创建用于Hibernate 4的Maven插件.该插件支持包括Envers在内的架构导出.工作示例如下.查看官方插件配置文档以获取有关使用的选项的说明.

Juplo has created Maven plugin for Hibernate 4. The plugin supports schema export including Envers. The working example is below. Check official plugin configuration documentation to get explanation for used options.

插件在test目标的Maven /target目录中生成schema.sql文件. 或者,您可以手动运行hibernate4:export目标来更新文件.

The plugin generates schema.sql file in the Maven /target directory on test goal. Or you can manually run hibernate4:export goal to update the file.

<project>
    <build>
        <plugins>
            <plugin>
                <groupId>de.juplo</groupId>
                <artifactId>hibernate4-maven-plugin</artifactId>
                <version>1.0.3</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>export</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <envers>true</envers>
                    <format>true</format>
                    <delimiter>;</delimiter>
                    <force>true</force>
                    <type>CREATE</type>
                    <target>SCRIPT</target>
                    <hibernateDialect>org.hibernate.dialect.PostgreSQL9Dialect</hibernateDialect>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

这篇关于如何使用org.hibernate.tool.EnversSchemaGenerator生成Envers数据库架构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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