java Hibernate Envers - 获取已更改的字段

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14125558/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 15:09:34  来源:igfitidea点击:

Hibernate Envers - Get Fields that have changed

javahibernateaudithibernate-envers

提问by RNJ

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

我有一个相当复杂的数据库结构,我正在尝试审核。目前我正在运行Envers,它会审核对每个对象所做的更改。这真的很好用!

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 Enversstores 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 Enversto store which fields have changed. Is this possible? I found thislink 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.

我现在想在 UI 上显示一些审计信息。对象/表变得非常复杂,所以我正在寻找一种方法来查看审计中哪些字段发生了变化。当前Envers存储每个对象的快照,并带有修订版 ID。我可以查看每个对象的修订,然后手动查询以查看发生了什么变化,但我想知道是否有办法Envers存储哪些字段发生了变化。这可能吗?我从 2011 年找到了这个链接,它建议手动检查每个对象字段。我关心的是速度。我有很多相关的对象,我可能只有一个更新的字段。我将不得不查询很多字段才能找到已更改的字段。

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

我应该说我正在使用 REVCHANGES 表,所以我可以看到哪些修订版发生了变化,但这只是在实体级别而不是字段级别

采纳答案by adamw

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

在较新的 Envers 版本中,您可以使用布尔标志跟踪每次修订时更改的属性。看:

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

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