envers property not found exception
saikiran.kulkarni Jan 15, 2013 8:26 AMHi,
I am working on envers...
I am able persist the entities with audit deatils by default implementations..
I want to add username to the revinfo so i extended defaultrevision class and i have written the revision listener ,,,
when run test givivng "
Caused by:
org.hibernate.PropertyNotFoundException
:
field [modifiedEntityNames] not found on com.arisglobal.entities.CustomRevisionEntity..
so plz help
//package com.arisglobal.entities;
//
//
//import javax.persistence.Entity;
//
//import org.hibernate.envers.DefaultRevisionEntity;
//import org.hibernate.envers.RevisionEntity;
//
//
//@Entity
//@RevisionEntity //(ImplementedRevisionListener.class)
//public class ExtendedRevisionEntity extends DefaultRevisionEntity {
//
//
//
//
//
//
// private String userName;
//
//
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
//
//
//
//
//}
package com.arisglobal.entities;
import java.io.Serializable;
import java.text.DateFormat;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.hibernate.envers.RevisionEntity;
import org.hibernate.envers.RevisionNumber;
import org.hibernate.envers.RevisionTimestamp;
@Entity
@Table(name="REVISIONS")
@RevisionEntity(CustomRevisionListener.class)
public class CustomRevisionEntity implements Serializable {
private static final long serialVersionUID = -1255842407304508513L;
@Column
@Id
@GeneratedValue
@RevisionNumber
private int id;
@Column
@RevisionTimestamp
private long timestamp;
@Column
private String username;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Transient
public Date getRevisionDate() {
return new Date(timestamp);
}
public long getTimestamp() {
return timestamp;
}
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public boolean equals(Object o) {
if(this == o) return true;
if(!(o instanceof CustomRevisionEntity)) return false;
CustomRevisionEntity that = (CustomRevisionEntity) o;
if(id != that.id) return false;
if(timestamp != that.timestamp) return false;
if(timestamp != that.timestamp) return false;
if(username != that.username) return false;
return true;
}
public int hashCode() {
int result;
result = id;
result = 31 * result + (int) (timestamp ^ (timestamp >>> 32));
return result;
}
public String toString() {
return "DefaultRevisionEntity(user = " + username + "id = " + id + ", revisionDate = " + DateFormat.getDateTimeInstance().format(getRevisionDate()) + ")";
}
}
package com.arisglobal.entities;
//
//import org.hibernate.envers.RevisionListener;
//
//public class ImplementedRevisionListener implements RevisionListener{
//
// public void newRevision(Object revisionEntity) {
// // TODO Auto-generated method stub
//
//
// ExtendedRevisionEntity extendedRevisionEntity = (ExtendedRevisionEntity) revisionEntity;
//
// extendedRevisionEntity.setUserName("saikiran");
//
//
//
// }
//
//}
import org.hibernate.envers.RevisionListener;
public class CustomRevisionListener implements RevisionListener {
public void newRevision(Object revisionEntity) {
CustomRevisionEntity revision = (CustomRevisionEntity) revisionEntity;
revision.setUsername("username"); //for testing
}
}