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()); } }
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; } }
Hello,
it should just be a normal entity, mapped as all other entities in your system. Maybe you have to include it in persistence.xml, or wherever you declare the other entities?
Adam