I updated Hibernate to the 4.1.1.Final version. According to the documentation There are 2 ways to generate a database schema:
org.hibernate.tool.ant.EnversHibernateToolTask
.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.
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>