Work around for envers auditing for bulk update

谁说胖子不能爱 提交于 2019-12-02 03:37:03

问题


In the application which I am working on I use spring, hibernate and envers for auditing. envers works with calls like, hibernateTemplate.insert, hibernateTemplate.save, hibernateTemplate.saveOrUpdate. But it doesnt seem to work when i call hibernateTemplate.bulkUpdate.

I googled for solutions and found that envers doesnt support bulkUpdate.

A work around has been provided in the link below but i am not able to get it.

Envers Bulk insert/updates

It would be of help if someone can provide a workaround/sample for this.

Thanks


回答1:


The documentation is correct. HQL and native SQL operations are not audited.

Since the performance of the bulk update will be affected by auditing, you may wish to change your design - for example, if you have a parent entity with related children, and you are performing a bulk update on the child records, you could update attributes of the parent record and then call saveOrUpdate after doing the bulk update.

Another option, is to manually perform the bulk update on the audit table(s) also, but its not going to be elegant. I managed to get around the issue in my case by changing the design as per the above.



来源:https://stackoverflow.com/questions/12370596/work-around-for-envers-auditing-for-bulk-update

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