
Envers 1.2.1.GA released! This release is based on the Hibernate-Envers module (which will be included in Hibernate 3.5), but is compatible with Hibernate 3.3. It contains all of the newest features and bugfixes. See the downloads and the documentation.
Envers moves to Hibernate! See the annoucement here and the update here.
The Envers project aims to enable easy auditing/versioning of persistent classes.
All that you have to do is annotate your persistent class or some of its properties, that you want to audit, with @Audited.
For each audited entity, a table will be created, which will hold the history of changes made to the entity.
You can then retrieve and query historical data without much effort.
Similarly to Subversion, the library has a concept of revisions. Basically, one transaction is one revision (unless the transaction didn't modify any audited entities). As the revisions are global, having a revision number, you can query for various entities at that revision, retrieving a (partial) view of the database at that revision. You can find a revision number having a date, and the other way round, you can get the date at which a revision was commited.
The library works with Hibernate and Hibernate Entity Manager (see hibernate.org). For the auditing to work properly, the entities must have immutable unique identifiers (primary keys). You can use Envers wherever Hibernate works: standalone, inside JBoss AS, with JBoss Seam or Spring.
Some of the features:
In the future, the library will include support for "revisioning groups", which will de-centralize the revisions table, if there are independend groups of entities audited. Another important space-saving feature will be the possibility to store only diffs between revisions, not whole properties (this of course applies only to strings and byte arrays).
For a quick tutorial on how to use the library, see the Quick Start page.
On the downloads page, you'll find the jar with the library, the source code, as well as an Envers+Seam demo: a simple wiki application and bi-temporal versioning demo.
You can also try a console demo, which is a simple app where you can create, modify and view versions of two simple entities
(Person and Address), and modify a one-to-many relation between them.
By default it uses hsqldb, but you can overwrite the persistence.xml and check how it works with your database, see the structure of the generated tables etc.