Hello all,
I want to use Hibernate Envers for auditing. A date field in the revision table would come in handy when matching revisions with logging timestamps in the application and server logs. And hurraah the Envers documentation states that it is possible to use a Date field:
Quote:
This entity must have at least two properties:
1. an integer- or long-valued property, annotated with @RevisionNumber. Most often, this will be an auto-generated primary key.
2. a long- or j.u.Date- valued property, annotated with @RevisionTimestamp. Value of this property will be automatically set by Envers.
( from:
http://docs.jboss.org/hibernate/envers/ ... onlog.html )
So, I configure Envers to use my own entity (note the auditingTimestamp field), in part because I want to log username and userid as well.
Code:
@RevisionEntity(MyRevisionListener.class)
@Entity
@Table(name = "KV_REV")
public class Revision {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@RevisionNumber
private Long id;
@RevisionTimestamp
@Temporal(TemporalType.TIMESTAMP)
private Date auditingTimestamp;
// more fields for username and id
Unfortunately this doesn't work: during build this error pops up:
Code:
org.hibernate.MappingException: The field annotated with @RevisionTimestamp must be of type long or Long
Am I doing something wrong here? What should I do to have the @RevisionTimestamp field mapping to a timestamp in the database?
Jan Peter
P.S. Hibernate Envers version is hibernate-envers-3.4.1.GA-hibernate-3.3.jar.