This is a follow up question to Retrieve audited entities name, old value and new value of the given revision
I have figured out how to get the two revision of an entity but don't see any easy to find the difference between the two. Is there anything in envers that will help doing a diff of an entity at different revisions? Or any good libraries?
I would be really cool if I could get the property modified (_mod) field fields.
There's no support for that in Envers currently. You will have to compare the objects yourself.
The Envers API is more for viewing the history. It won't tell you what changed but you can fetch two revisions and looks for differences. The fact is, it doesn't store what changed, it stores all the fields of that entity at that point in time. It would have to compare each one to figure out the differences, so you will need to write that code.
So what I came up with to make life easier was to create an annotation to mark the fields I was interested in comparing. Without I ended up having to get with sticking to naming conversation like only only using methods that start with 'get'. I found there was a lot of corner cases with this approach.
The annotation.
which gets used like
Since envers audits both the Set changing and the object of the set as two different events I didn't want to compare if the set change. Then to do the comparison I have method that looks like