Hibernate envers - 如何只存储更新的值 [英] Hibernate envers - How to store only updated values
问题描述
我有一个需求,只需要审计审计表中更新的列(例如employee_aud)。
默认情况下,envers会将整个持久化实体插入到审计表中。
我只需要插入更新的值。
有没有可能做到这一点?
预先致谢。
干杯!
当您使用 @Audited
注解实体时,您正在控制Envers在发生更改时应检查哪些属性。然后这些属性在旧状态和新状态之间进行比较,如果有任何不同,Envers将为所有审计属性编写一个新的审计记录,其中包含新的状态值。
其他单词,Envers不会只编写一个新的审计行,只有您为了审计而修改的属性。如果任何审计属性发生变化,它将编写一个新的审计行。
I am using Hibernate Envers for my Auditing. Post-update and post-insert works fine.
I have a requirement where I need to audit only the updated columns in the audit table (e.g. employee_aud). By default envers will insert the entire persisted entity in to the audit table.
I need to insert values only which are updated.
Is there any possibility to do this ?
Thanks in advance.
Cheers !
When you annotate an entity with @Audited
, you're controlling which properties Envers should inspect when changes occur. Those properties are then compared between the old and new state and if any differ, Envers will write a new audit record with the new state values for all audited properties.
In other words, Envers won't write a new audit row with only the modified properties you have toggled for audit. It will write a new audit row with all audited properties if any of them change.
这篇关于Hibernate envers - 如何只存储更新的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!