Hibernate.orgCommunity Documentation

Chapter 5. Tutorial Using Envers

5.1. persistence.xml
5.2. The annotated entity Java class
5.3. Example code
5.4. Take it further!

This tutorial is located within the download bundle under envers.

Objectives

This file was discussed in the JPA tutorial in Section 4.1, “persistence.xml, and is essentially the same here.

Again, the entity is largely the same as in Section 4.2, “The annotated entity Java class”. The major difference is the addition of the @org.hibernate.envers.Audited annotation, which tells Envers to automatically track changes to this entity.

Again, this tutorial makes use of the JPA APIs. However, the code also makes a change to one of the entities, then uses the Envers API to pull back the initial revision as well as the updated revision. A revision refers to a version of an entity.