title: Hibernate interceptors
body: <p>I am trying to implement method described <a href="https://sites.google.com/a/pintailconsultingllc.com/java/Home/hibernate-interceptor-for-new-entities" rel="nofollow">here</a>, but can't make it work.</p>
  
  <p>There are no errors during compilation, but the interceptor never fired.</p>
  
  <p>DAO:</p>
  
  <pre><code>public class GeneralInvoicesDAO {
  @Autowired
  private SessionFactory sessionFactory;
  
  @Autowired
  private Interceptor entityInterceptor;
  
     @Transactional
     public void update(GeneralInvoice object) {
        Session session = SessionFactoryUtils.getSession(sessionFactory, entityInterceptor, null);
  
        session.saveOrUpdate(object);
     }
  }
  </code></pre>
  
  <p>The intercepter class:</p>
  
  <pre><code>public class NewEntityInterceptor extends EmptyInterceptor implements Interceptor {
      /**
       * 
       */
      private static final long serialVersionUID = 2914362528125673753L;
  
      @Override
      public Boolean isTransient(Object n) {
           Logger logger = Logger.getLogger(getClass().getName());
  
           try {
               logger.warn("test");
               Boolean result = Boolean.FALSE;
  
               BaseEntity entity = (BaseEntity) n;
               if (entity.getId() &lt;= 0L) {
                   entity.setId(null); 
                   result = Boolean.TRUE;
               }
               logger.warn(result.toString());
               return result;
          }
          catch (Exception e) {
              e.printStackTrace();
              return super.isTransient(n);
          }
       }
  }
  </code></pre>
  
  <p>Config:</p>
  
  <pre><code>&lt;bean id="newEntityInterceptor" class="de.crm.interceptor.NewEntityInterceptor" /&gt;
      &lt;bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
          &lt;property name="entityInterceptor" ref="newEntityInterceptor" /&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>What's wrong?
  Thank you</p>