19

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

RNJ
  • 15,272
  • 18
  • 86
  • 131
  • 3
    +1 for this - We're currently using the old onPostUpdate listener to do a diff and recording the diff in a table when the updates are made. Ideally Envers querying would tell us: 1. What has changed and for extra credit: 2. What it changed from and to – ndtreviv Feb 12 '13 at 16:02

1 Answers1

9

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

adamw
  • 8,038
  • 4
  • 28
  • 32
  • 9
    The problem with this is that as far as I can tell, there is no way to programmaticly check this information. You can only use it in audit queries. That helps limit the revisions you bring in, but is no help at all sanely displaying a log of what happened. If I understand the original poster right, and for my own problem, I need a way to access these flags AFTER the revisions are loaded so I can sanely show the user what changed. Otherwise the log is useless because it takes to long to figure out what changed. – user3402489 May 05 '15 at 20:32