Hibernate Envers - 获取已更改的字段 [英] Hibernate Envers - Get Fields that have changed

查看:28
本文介绍了Hibernate Envers - 获取已更改的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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!

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

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?

谢谢

编辑

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

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

推荐答案

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

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

这篇关于Hibernate Envers - 获取已更改的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆