1 Reply Latest reply on Jul 16, 2009 9:22 AM by adamw

    RevisionListener is not being called

      Hi there,

      Hopefully this is the last question for this. :)

      I have a class that implements the revisionlistener

      package za.co.aforbes.fpc.db.model;
      
      import org.hibernate.envers.RevisionListener;
      
      import za.co.aforbes.fpc.db.model.user.User;
      import za.co.aforbes.fpc.ui.bean.ManagedBean;
      import za.co.aforbes.fpc.ui.util.FacesUtils;
      
      public class MyListener implements RevisionListener{
      
       @Override
       public void newRevision(Object obj) {
       MyTestEntity n = (MyTestEntity)obj;
       n.setUsernameModified(((User)FacesUtils.getManagedBean(ManagedBean.CurrentUser)).getPrimaryId());
       }
      
      
      }
      


      and an entity

      package za.co.aforbes.fpc.db.model;
      
      import javax.persistence.Entity;
      import javax.persistence.GeneratedValue;
      import javax.persistence.Id;
      
      import org.hibernate.envers.RevisionEntity;
      import org.hibernate.envers.RevisionNumber;
      import org.hibernate.envers.RevisionTimestamp;
      
      @Entity
      @RevisionEntity(MyListener.class)
      public class MyTestEntity {
       @Id
       @GeneratedValue
       @RevisionNumber
       private int id;
      
       @RevisionTimestamp
       private long timestamp;
      
       private String usernameModified;
      
       public int getId() {
       return id;
       }
      
       public void setId(int id) {
       this.id = id;
       }
      
       public long getTimestamp() {
       return timestamp;
       }
      
       public void setTimestamp(long timestamp) {
       this.timestamp = timestamp;
       }
      
       public String getUsernameModified() {
       return usernameModified;
       }
      
       public void setUsernameModified(String usernameModified) {
       this.usernameModified = usernameModified;
       }
      
      
      
      }
      



      But when i update any thing my audit tables are being updated but my listener is not being called.

      Questions:

      1. Is my entity supposed to be mapped in my hibernate.cfg.xml file for it to register?

      2. If not how do i register the Entity in my application?

      Thanks ,
      Muhammed Patel