Hibernate Envers : How to delete entries from my audit table?

Posted by Laurent T on Stack Overflow See other posts from Stack Overflow or by Laurent T
Published on 2010-05-07T19:22:57Z Indexed on 2010/05/07 19:28 UTC
Read the original article Hit count: 212

Filed under:
|
|
|

Hi everyone,

I am currently working with Hibernate Envers. My problem is the following :

How to delete entries in the audit table related to the entity I want to delete?

My entity has no relation with other entities.

I figured out that I have to do that in onPostDelete method of my custom listener :

import org.hibernate.envers.event.AuditEventListener;
import org.hibernate.event.PostCollectionRecreateEvent;
import org.hibernate.event.PostDeleteEvent;
import org.hibernate.event.PostInsertEvent;
import org.hibernate.event.PostUpdateEvent;
import org.hibernate.event.PreCollectionRemoveEvent;
import org.hibernate.event.PreCollectionUpdateEvent;

public class MyListener extends AuditEventListener {

  ...
  @Override
  public void onPostDelete(PostDeleteEvent arg0) {
    // TODO Auto-generated method stub
    super.onPostDelete(arg0);
  }
  ...

}

I've read the documentation, forums, many things but I can't figure it out. May be it's not possible, I don't know.

Has someone ever done this before?

Thank you :)

© Stack Overflow or respective owner

Related posts about hibernate

Related posts about envers