Adam Warski

3 Sep 2008

Envers is back from vacations

envers
java
hibernate

Hello,

after a vacation break, Envers is back with a 1.1.0.beta1 release. You can find the release notes here.

There’s quite a lot of changes and improvements in this release. Firstly, Envers now only works with Hibernate 3.2.6 or Hibernate 3.3.0. That is because support (not yet complete) for persistent collections is added – and that requires collection event listeners, which were introduced in Hibernate 3.2.6.

However, thanks to the new listeners, you can now version many-to-many relations and unidirectional one-to-many relations (except for the mapping @OneToMany+@JoinColumn, which will be supported later).

Other improvements include:

  • a configuration option (org.jboss.envers.unversionedOptimisticLockingField) to automatically unversion fields in entities annotated with @Version, contributed by Nicolás Doroskevich

  • an @Unversioned annotation, which lets you exclude some fields from versioning, while keeping the entity-wide @Versioned annotation, contributed by Sebastian Komander

  • a new implementation of the query system, which provides room for future improvements

  • the revisions-of-entity query returns now by default a list of triples: the entity that was modified, revision entity containing all revision data and the revision type (see the beta javadoc for details); all this is read using only one database query; there are also slight API changes in version queries

  • for Maven2 users, Envers is now deployed to JBoss’s repository, http://repository.jboss.org/maven2/org/jboss/envers/jboss-envers/.

I’d like to welcome and thank two new contributors: Nicolás and Sebastian. Don’t hesitate to follow their way :). As always, all forum users were very helpful in finding bugs and suggesting new ideas.

Finally, some updates on configuration. The Envers home page doesn’t yet reflect this (as it’s still a beta release). To use the new collection listeners, be sure that your persistence.xml includes the following:

    
    Or if you are using Envers directly with Hibernate:
    
    ```xml
<event type="post-insert">
<listener class="org.jboss.envers.event.VersionsEventListener"/>
</event>
<event type="post-update">
<listener class="org.jboss.envers.event.VersionsEventListener"/>
</event>
<event type="post-delete">
<listener class="org.jboss.envers.event.VersionsEventListener"/>
</event>
<event type="pre-collection-update">
<listener class="org.jboss.envers.event.VersionsEventListener"/>
</event>
<event type="pre-collection-remove">
<listener class="org.jboss.envers.event.VersionsEventListener"/>
</event>
<event type="post-collection-recreate">
<listener class="org.jboss.envers.event.VersionsEventListener"/>
</event>
If you are using Envers with JBoss AS 4.2.x, you&#8217;ll have either to bundle the hibernate jars with your application, or upgrade hibernate in the `lib` directory of the AS, as the versioned used there is 3.2.4.SP1.

As always, waiting on the [forums][5] for your opinions and for bug reports in [JIRA][6].

Adam
comments powered by Disqus

Any questions?

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