Work around for envers auditing for bulk update

前端 未结 1 1381
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-22 17:52

In the application which I am working on I use spring, hibernate and envers for auditing. envers works with calls like, hibernateTemplate.insert, hibernateTemplate.

1条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-22 18:03

    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.

    0 讨论(0)
提交回复
热议问题