Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate Envers - Get Fields that have changed

I have a rather complicated DB structure that I am trying to audit. Currently I have Envers running and it audits the changes that are made to each object. This works really well!

I now want to show some audit information on the UI. The objects/tables get quite complicated so I was looking for a way to see what fields have changed in the audit. Currently Envers stores a snapshot of each object stamped with a revision id. I can look at each object's revision and then manually query to see what has changed but I was wondering if there was a way I can get Envers to store which fields have changed. Is this possible? I found this link from 2011 and it recommends checking each object field manually. My concern here is speed. I have lots of objects related and I may only have one updated field. I will have to query a lot of fields to find the one that has changed.

Is it possible to store the fields that have changed?

Thanks

EDIT

I should have said that I am using the REVCHANGES table so I can see what has changed at what revisions but again this is only at entity level not field level

like image 847
RNJ Avatar asked Jan 02 '13 16:01

RNJ


1 Answers

In newer Envers versions you can track which properties changed at each revision using a boolean flag. See:

http://docs.jboss.org/hibernate/core/4.1/devguide/en-US/html/ch15.html#envers-tracking-properties-changes

like image 133
adamw Avatar answered Sep 21 '22 03:09

adamw