3 Replies Latest reply on Apr 21, 2010 1:08 PM by Alex Schefer

    RevisionListener not being called

    Alex Schefer Newbie

      Hello,

       

      I'm trying to follow the example in the documentation Chapter 4 about logging data for revisions. I'm using Hibernate 3.5.1 through Spring 2.5.4 with Oracle 10g and Tomcat  6.

       

      Like the example in the documentation, I just need to record the user in addition to the default revision fields. I'm assuming that if I don't specify another table name it will continue to use the REVINFO table and that I need to add a column to REVINFO for the new field, but I haven't got that far. So far I added what I believe is the correct entity and listener below, but nothing happens. On save or update no break points ever get hit in my listener. Is there anything else I need to do to plug in this listener in to Spring?

       

      Any help is MUCH appreciated!!

       

      Here's my code:

       

      public class RevisionListener implements org.hibernate.envers.RevisionListener
      {
          @Override
          public void newRevision(Object defaultEntity)
          {
                       MyRevisionEntity revisionEntity = (MyRevisionEntity) defaultEntity;

       

                       revisionEntity.setLastUpdateUser("testUser");
          }

      }

       


      @Entity
      @RevisionEntity(RevisionListener.class)
      public class MyRevisionEntity extends DefaultRevisionEntity
      {
          private static final long serialVersionUID = 1L;
         
          private String lastUpdateUser;
         
          public String getLastUpdateUser()
          {
              return lastUpdateUser;
          }
          public void setLastUpdateUser(String lastUpdateUser)
          {
              this.lastUpdateUser = lastUpdateUser;
          }
      }