Hibernate Envers : How to Implement a Conditional Audit Log

preview_player
Показать описание
Today, I want to show you how to implement a conditional audit with Hibernate Envers.
Envers automatically integrates with Hibernate ORM and provides a powerful and easy to use solution to write an audit log. As I described in previous videos, you just need to add Envers to your classpath and annotate your entities with @Audited. It will then document all insert, update and delete operations and you can even perform complex queries on your audited data and customize the revision information.
Sounds quick and easy, right?
Well, it is, as long as you audit all changes performed on an entity. But implementing a conditional audit requires more work. By default, Hibernate Envers registers a set of event listeners which are triggered by Hibernate ORM. You need to replace these listeners to customize Envers’ audit capabilities.

If you like this video, please give me your thumbs up and share it with your friends and co-workers.

Like my channel? Subscribe!

Join the free Member Library:

Want to connect with me?
Рекомендации по теме
Комментарии
Автор

Hello,
Thanks for the solution, but i think something is missing :
When you append a new listener, for example a PostUpdateEventListener, it doesn't mean that EnversPostUpdateEventListener is not active anymore, the system will invoke my listener then hibernate-envers' listener -> it will audit in any case

khaledbenahmed
Автор

Amazing explanation as usual! Thank you!

To add a thumbs up to the video, I needed to copy the URL from your website and do it in youtube, I suggest adding a more straight forward way to do this.

danielaphonso
Автор

Awesome!

I'm working with spring boot 2 (Hibernate 5). I had to set up in application.properties:



Thank you!

JulliermeBarros
Автор

Hmm. Good video. But I don't think your video retention stats are good. Because, your videos are informative but not not interesting. Hope this is a constructive criticism. Thanks for the effort!

hariharak