Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hibernate envers does not get triggered for jpa queries

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

like image 774
lives Avatar asked Apr 22 '14 15:04

lives


People also ask

How Hibernate Envers works?

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.

What is revtype in Envers?

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 ).

How does JPA handle null values?

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.

What is Envers?

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.


1 Answers

As mentioned in this and this post, envers is not triggered in your situation.

Also check out this related question in the JBoss forum

like image 185
geoand Avatar answered Sep 29 '22 12:09

geoand