Hibernate Envers - Get Fields that have changed

2019-04-19 09:21发布

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

1条回答
何必那么认真
2楼-- · 2019-04-19 09:25

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

查看更多
登录 后发表回答