Good to know this Hibernate Envers API changes

Today I tried to update the hibernate version for an internal customer project from 3.6.0.Final to 3.6.9.Final. In the project we are using Envers to track entity revisions. I already posted about that here.

I noticed that some tests broken with the new version. These tests doing something like this: „create a bean, do changes X times, check available revisions and changed properties from rev A to B“.  In the new version I missed some changed properties.  I’m so happy that we have some tests for that aspect because without them I guess I had found these effects.

I found  this entries in the Envers user forum:

– Envers not auditing properties in super class
– Envers modification in Hibernate 3.6.8 is causing problems

Then I use the „try and fail“ principle to find the latest working version: ONLY 3.6.0.Final works 😀

So there was an API change from 3.6.0.Final to 3.6.1.Final. Since 3.6.1.Final Envers doesn’t inspect parent class (es) per default to find out the audit able properties. But it’s easy to fix that:

  • put a @Audited to all the base classes
  • or use org.hibernate.envers.Audited.auditParents() (if you can’t change the base class)