Hibernate envers - How to store only updated values

本小妞迷上赌 提交于 2019-12-20 03:42:21

问题


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 !


回答1:


What happens if you dont configure envers listener for post-insert?

I mean if you take out post-insert listener from your config?

 <listener class="org.hibernate.envers.event.AuditEventListener" type="post-insert"/>



回答2:


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.



来源:https://stackoverflow.com/questions/12800540/hibernate-envers-how-to-store-only-updated-values

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