I am using hibernate envers to audit events and it works fine along with Spring Data JPA Repository when i invoke repositoy.delete() or repository.save()
But If I write a jpa query and delete the entity using a query , then it hibernate envers audit listener does not get invoked.
I read that hibernate envers will not trap native query - But will it not work for hibernate/jpa queries as well ?
Thanks Lives
Hibernate Envers provides a very simple solution for CDC (Change Data Capture). It uses the Hibernate Event system to intercept all entity state transitions and audit them. The database transaction will roll back and both the actual changes and the audit log is rolled back.
org.hibernate.envers.revision_type_field_name (default: REVTYPE ) Name of a field in the audit entity that will hold the type of the revision (currently, this can be: add , mod , del ).
The JPA specification defines that during ordering, NULL values shall be handled in the same way as determined by the SQL standard. The standard specifies that all null values shall be returned before or after all non-null values. It's up to the database to pick one of the two options.
The Envers module is a core Hibernate model that works both with Hibernate and JPA. In fact, you can use Envers anywhere Hibernate works whether that is standalone, inside WildFly or JBoss AS, Spring, Grails, etc. The Envers module aims to provide an easy auditing / versioning solution for entity classes.
As mentioned in this and this post, envers is not triggered in your situation.
Also check out this related question in the JBoss forum
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With