简体   繁体   中英

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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