i'm using Hibernate Envers,my customer RevisionEntity is:
@Entity
@RevisionEntity(SimpleListener.class)
@Table(name = "data_rev_info")
public class SimpleRevisionEntity {
@Id
@GeneratedValue
@RevisionNumber
@Column(name = "revision_id")
private long id;
@RevisionTimestamp
@Column(name = "revision_timestamp")
private Date timestamp;
/**
* @return the id
*/
public long getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(long id) {
this.id = id;
}
/**
* @return the timestamp
*/
public Date getTimestamp() {
return timestamp;
}
/**
* @param timestamp the timestamp to set
*/
public void setTimestamp(Date timestamp) {
this.timestamp = timestamp;
}
}
i can use auditReader to get audit time of a specific revision id
AuditReader auditReader = AuditReaderFactory.get(em);
Date date = auditReader.getRevisionDate(n);
if i add a additonal field in SimpleRevisionEntity, named actor(type is String),how to get this addtional field by using AuditReader? Also if i want to query audit logs generated in the last five minites,how to?
To get the value of the actor
field, you need to find the revision entity. It's a normal entity, so you can simply look it up by id using Hibernate, or using the AuditReader.findRevision(revisionEntityClass, revision)
method.
As to querying for revisions generated in the last 5 minutes, I would do a query on the revision entity specifying that the timestamp
column must be >= NOW()-5 minutes
(that's pseudo-code, of course :) ).