-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: @RevisionTimestamp can't use Date?
PostPosted: Tue Sep 20, 2011 3:29 am 
Newbie

Joined: Mon Sep 19, 2011 11:16 am
Posts: 2
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.