I updated Hibernate to the 4.1.1.Final version. According to the documentation There are 2 ways to generate a database schema:
- Ant task
org.hibernate.tool.ant.EnversHibernateToolTask
. - 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.
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 ontest
goal. Or you can manually runhibernate4:export
goal to update the file.The following worked for me:
You don't need Ant or Hibernate tools. It's pretty easy to just use the EnversSchemaGenerator directly, like this:
You can also give it a file name to write to, but the code above will print to the syslog anyway.
I have got the same problem. Now there is a Hibernate 4 Tools version:
But this Ant fragment does not export the audit tables, only the "basic" tables:
Same with this code: Only "basic", no "_aud" tables:
Are you still interested? I'll let you know if I find out how to solve the problem. Maybe somebody else has got any advice for us?