
The Envers project aims to enable easy versioning of persistent classes.
All that you have to do is annotate your persistent class or some of its properties, that you want to version, with @Versioned.
For each versioned entity, a table will be created, which will hold the history of changes made to the entity.
Similarly to Subversion, the library has a concept of revisions. Basically, one transaction commit is one revision (unless the transaction didn't modify any versioned 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.
Currently, the library has the following features:
The library works with the latest Hibernate and Hibernate Entity Manager versions (see hibernate.org). For the versioning to work properly, the entities must have immutable unique identifiers (primary keys).
In the future, the library will support versioning of arbitrary relationships. It will also provide greater configurability; right now all names of columns and tables generated by the library are fixed. 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).
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: an extremely simple wiki application, which lets you to create and edit pages, view their history and check which users made the changes.
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.