6

I am using Hibernate Envers to audit my entities and properties (org.hibernate.envers.global_with_modified_flag=true). This seems to work, but now I'd like to get all properties of a specific entity which changed at a given revision, compared to the previous one. As a bonus, it would be nice to get the changeset from one revision to another one. So far, I only get the modified entities:

List<Object> modifiedClassesAtRevision = getAuditReader().getCrossTypeRevisionChangesReader().findEntities(revision, RevisionType.MOD)
Object modifiedObject = modifiedClassesAtRevision.get(0);

Now, since I do not want to create comparison methods for all entities in Java, is there any way to get the modified properties of this revision? Something along the lines of

List<String> modifiedProperties = getAuditReader().getModifiedProperties(modifiedObject, revision);

would be nice to have - but maybe I am just too stupid to find that kind of feature.

Dominik Sandjaja
  • 6,326
  • 6
  • 52
  • 77

1 Answers1

4

Currently it's only possible to query for entities where a property was modified, see http://docs.jboss.org/hibernate/core/4.1/devguide/en-US/html/ch15.html#envers-envers-tracking-properties-changes-queries.

Getting a descriptor (changeset) of which properties changed is not yet possible.

adamw
  • 8,038
  • 4
  • 28
  • 32
  • 1
    Thanks, I had seen that querying option, just wasn't sure if the listing of changed properties was just not mentioned in the documentation or if it actually IS missing. Now I know that it is the latter ;-) As a workaround I fetch the old version and the new version and use `BeanUtils` and `PropertyUtils` to iterate over all properties and compare their values. Not nice, but it works for now. :-) – Dominik Sandjaja Feb 13 '13 at 20:45