Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Hibernate Envers without auto generating DDL

I am using Spring + MySQL and Hibernate in my application. I wanted to start using Envers as an audit log, but as I understand, in order to use it I must enable Hibernate to create DDL.

Is there a way to use Envers without letting Hibernate create DDL, or even better, create DDL only for Envers tables?

If not, is there a way to tell Hibernate to export the DDL to a file instead of the DB so I can take only what I need?

like image 554
Noam Nevo Avatar asked Jan 26 '26 05:01

Noam Nevo


1 Answers

You don't have to enable automatic DDL creation in order to use Envers.

You can simply create the schema yourself. Basically each audited table gets a mirror table with an _AUD suffix, plus the revision columns.

Schema generation is available via the schemaexport ant task, see here: http://docs.jboss.org/hibernate/core/4.1/devguide/en-US/html/ch15.html#envers-generateschema

Also, you can simply generate the DDL on a local database and use it as a reference to apply to other databases.

like image 153
adamw Avatar answered Jan 28 '26 19:01

adamw



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!