Adam Warski

12 Jun 2008

Envers beta – now with queries!


So far Envers made it easy to store historical data; now, with version 1.0.0.beta1 (download here), you can also query it, in two “dimensions”: for entities at a given revision and for revisions, at which an entity changed. The implementation mostly follows Hibernate Criteria, with some features removed, and some added.

For example the following query returns all persons with the name “John”, sorted by their surname, which lived at the address with the given id at revision 12:

List personsAtAddress =
      .forEntitiesAtRevision(Person.class, 12)
            "address", addressId))
      .add(VersionsRestrictions.eq("name", "John"))

You can find more information about creating queries on this page.

Warning – the schema generated by this version of Envers is incompatible with the schema generated by the preview versions. If you have any data to migrate, please write on the forum. As this is the beta release, there will be no more schema changes until the 1.0 final release.

Thanks to the forum users: talios, aamonten, genman, liuxiaodu and others for bug reports, patches, testing and ideas!

Finally, the release notes for this release are located here.

As always, waiting for comments and bug reports :)


comments powered by Disqus

Any questions?

Can’t find the answer you’re looking for?