7

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

lives
  • 1,243
  • 5
  • 25
  • 61
  • 1
    I think your problem could be this: For query based data manipulation no lifecycle callbacks will be triggered and no cascades will be triggered on the level of the persistence context. This means, entity listeners listening to an @PreUpdate event will not get notified. Also any cascade operations - http://stackoverflow.com/questions/23173273/how-to-override-a-delete-method-on-a-spring-data-crudrepository?noredirect=1#comment35489769_23173273 – gipinani Apr 22 '14 at 15:06

1 Answers1

5

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

Also check out this related question in the JBoss forum

Community
  • 1
  • 1
geoand
  • 60,071
  • 24
  • 172
  • 190