简体   繁体   English

Hibernate Envers将当前数据条目替换为先前的审核表条目

[英]Hibernate Envers replace current data entry with previous audit table entry

I've been using hibernate envers to for auditing purpose in my spring-boot app but there's a requirement where I need to give an option to revert to the previous record from the audit table. 我一直在Spring-boot应用程序中使用hibernate envers进行审计,但是有一个要求,我需要提供一个选项以还原到审计表中的先前记录。

In the present case, I'm fetching the data from the audit table and updating the base table. 在当前情况下,我正在从审计表中获取数据并更新基表。 So is there any better way to do this? 那么,有什么更好的方法吗?

That is the recommended approach. 这是推荐的方法。

Envers does not provide a feature where you can specify that it attempt to restore from an audited snapshot simply because your entity mapping may only audit a subset of fields so its best to leave that open for interpretation by the application. Envers没有提供一项功能,您可以指定它尝试从已审核的快照还原,这仅仅是因为您的实体映射可能仅审核字段的子集,因此最好将其保留以供应用程序解释。

So yes, you'd fetch the audit snapshot of interest, overlay that data atop of your current entity data from the main table and then merge those changes to the persistence context. 因此,是的,您将获取感兴趣的审计快照,将该数据从主表覆盖在当前实体数据之上,然后将这些更改合并到持久性上下文中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM