Domanda

I am using envers to audit a User class and it saving all modified data in DB with rev number. Now, i need to recover all edited entities name, old value and new value by passing revision number as parameter.

I have read envers doc but could not find any solution for it.

Can anyone please suggest? thanks

È stato utile?

Soluzione

A revision number uniquely identifies a version of an entity, hence when getting an entity at a specific revision, you get it with the values it had back then.

To get the old and new values of fields, if you know the entity has been changed at revision N, the easiest way is to get the entity at revisions N-1 and N and compare the fields you are interested in.

This can be done in a single query using the forRevisonsOfEntity query (see the AuditReader and AuditQueryCreator javadocs)

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top