Looking for Envers documentation here http://docs.jboss.org/envers/docs/index.html#revisions-of-entity
I'm trying to query for revisions (LIST!) where a specific object property is changed. In the documentation example you have a person class with id, name, surname and address.
The paragraph 5.2 show how to find a specific revision where some maximized/minimized condition are satisfied.
I can find all the revision where a specific class instance is changed
auditReader.getRevisions(entityClass, entityName, id);
But this is not a query.
I'm trying to do something like (given entityClass, id and attributeName?):
auditReader.createQuery().forRevisionsOfEntity(entityClass, false, true)
.add(AuditEntity.id().eq(id))
.add(AuditEntity.property(attributeName).ne(AuditEntity.GETPREVIOUS?().property(attributeName)))
In other words, as hibernate envers documentation, I'm searching all the person revision with one id (= one person), where only the name is changed (address can change in the middle multiple times).
I don't know how exacly write the restriction to the query, to see the change to only one attribute, or how to write the attribute is different from the previous revision of this object.
Thank you
Francesco
To query for property changes, you will need to include property change markers for some or all properties of your entities, in the audit entities. This is a feature of a newer version of Envers, present in Hibernate 4.1.
See the docs: http://docs.jboss.org/hibernate/core/4.1/devguide/en-US/html/ch15.html#envers-envers-tracking-properties-changes-queries