Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Hibernate Envers work?

I am using Hibernate envers in one of my projects. It works really good and does that job.

I am trying to understand the internal working mechanism of envers.

  1. How does envers work internally?

  2. What happens when the actual transaction is succeeded and the audit table update fails? Will the entire transaction be rolled back?

  3. Does envers be executed in a different thread than the actual one serving the request? or can it be?

like image 354
zeagord Avatar asked Nov 14 '25 09:11

zeagord


1 Answers

Hibernate Envers provides a very simple solution for CDC (Change Data Capture).

  1. It uses the Hibernate Event system to intercept all entity state transitions and audit them.
  2. The database transaction will roll back and both the actual changes and the audit log is rolled back.
  3. No. Envers is a synchronous audit logging mechanism. For asynchronous audit logging, you need to use Debezium.

If you want to use Envers, make sure you are using the validity audit strategy because it performs better than the default one.

like image 145
Vlad Mihalcea Avatar answered Nov 17 '25 05:11

Vlad Mihalcea



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!