1 Reply Latest reply on Jul 7, 2009 3:10 PM by Ashish Tonse

    Hibernate Interceptor in Seam

    Bhuvanesh Phadnis Newbie


      I am trying to write an interceptor for Entity beans to log CRUD actions. Can someone tell me how to implement a Hibernate interceptor in Seam?

      Thanks for your time


        • 1. Re: Hibernate Interceptor in Seam
          Ashish Tonse Newbie

          The way I did it:

          - Create a class that extends org.hibernate.EmptyInterceptor.

          package myapp.service.util;
          import java.io.Serializable;
          import org.hibernate.CallbackException;
          import org.hibernate.EmptyInterceptor;
          import org.hibernate.type.Type;
          public class EntityInterceptor extends EmptyInterceptor {
               public void onCollectionUpdate(Object collection, Serializable key)
                         throws CallbackException {
                    super.onCollectionUpdate(collection, key);
               public boolean onSave(Object entity, Serializable id, Object[] state,
                         String[] propertyNames, Type[] types) {
                    boolean changed = false;
                      put any changes on save here
                    return changed;

          - Configure it in your persistence file with the following line:

          <property name="hibernate.ejb.interceptor" value="myapp.service.util.EntityInterceptor" />