Hibernate Envers - Get Fields that have changed

筅森魡賤 提交于 2019-12-06 19:37:28

问题


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:


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



来源:https://stackoverflow.com/questions/14125558/hibernate-envers-get-fields-that-have-changed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!