Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate Envers database schema with org.hibernate.tool.EnversSchemaGenerator?

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

  1. Ant task org.hibernate.tool.ant.EnversHibernateToolTask.
  2. Run org.hibernate.tool.EnversSchemaGenerator from Java.

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?

Update:

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

like image 828
Viacheslav Dobromyslov Avatar asked Mar 10 '12 15:03

Viacheslav Dobromyslov


1 Answers

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.

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>
like image 197
Viacheslav Dobromyslov Avatar answered Jan 01 '23 21:01

Viacheslav Dobromyslov