Recently, I wanted to keep the change history of entities saved via Hibernate and also have a versioned database. Hence, I used Hibernate Envers and Liquibase.
The tables for envers, both the revinfo table and the _AUD tables for each entity, have to be included in the changeset of Liquibase:
The autoIncrement=”true” in the revinfo table is quite important. Without it, new revisions don’t have an ID and this exception occurs:
The best way to prevent this exception from happening is the mentionend autoIncrement. However, it’s also possible to create an entity for the revision:
Here’s a great article about “The best way to implement an audit log using hibernate envers” by Vlad Mihalcea.