This is a community-edited FAQ where you can describe the most common problems you encounter when using Envers and how to solve them. So feel free to edit this document!
Where can I find Envers documentation?
Envers documentation is now part of the Hibernate User guide, for Hibernate 5.x see: http://docs.jboss.org/hibernate/stable/orm/userguide/html_single/Hibernate_User_Guide.html#envers
Using Envers with Maven
Firstly you need to add the JBoss repositories either to your Maven settings, or to your pom.xml. See here for a description of how to do that.
For the current, Hibernate-5/4/3.6 compatible versions, you should use the new group and artifact ids. Use this dependency:
(You'd want to match the version number with e.g. hibernate-core and hibernate-entitymanager)
If you want to use the older, Hibernate-3.3 compatible versions, use the old group and artifact add this dependency to your pom.xml:
Filling in a revision entity with information obtained from Spring beans
See this forum disucssion:
Problems with using Spring and Envers
- Check your transaction configuration and that the transaction is commited
- See the blog post: http://ourcraft.wordpress.com/2008/12/17/the-final-answer/
Dynamically configuring Envers using Spring
How to enable/disable auditing at runtime for versions 3.x/4.x?
This is in fact quite easy and doesn't require any specific support on the Envers side. All you need to do is subclass the AuditEventListener class and override the methods that are called on Hibernate events: onPostInsert, onPostUpdate, onPostDelete, onPreUpdateCollection, onPreRemoveCollection and onPostRecreateCollection. There, you can check if the change should be audited (you have access to the name of the entity and the entity object itself) and if so, pass the call to the superclass. The only difference to normal Envers configuration is that you have to specify your class as the listener for the events.
Grails + Envers
See this discussion: http://www.nabble.com/Grails-1.1.1-%2B-Envers-1.2.1.GA-td25530411.html