1 package de.spring.example.persistence.domain.audit;
5 import javax.persistence.Column;
6 import javax.persistence.Entity;
7 import javax.persistence.GeneratedValue;
8 import javax.persistence.GenerationType;
9 import javax.persistence.Id;
10 import javax.persistence.Table;
11 import javax.persistence.Temporal;
12 import javax.persistence.TemporalType;
14 /** import org.hibernate.envers.DefaultRevisionEntity; **/
15 import org.hibernate.envers.RevisionEntity;
16 import org.hibernate.envers.RevisionNumber;
17 import org.hibernate.envers.RevisionTimestamp;
19 import com.fasterxml.jackson.annotation.JsonFormat;
22 @RevisionEntity(MyCustomRevisionListener.class)
23 @Table(name="CUSTOM_REVISION", schema="mybatis_example")
24 public class MyCustomRevision /** extends DefaultRevisionEntity **/ {
27 @GeneratedValue(strategy=GenerationType.IDENTITY)
28 @Column(name="ID", updatable=false, nullable=false)
32 @Column(name="REVISION_DATE")
33 @Temporal(TemporalType.TIMESTAMP)
35 @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
36 private Date revisionDate;
38 @Column(name="USERNAME")
39 private String username;
41 // It will be used by JPA when filling the property fields with data coming from data base.
42 protected MyCustomRevision() {
46 // It will be used by my code (for example by Unit Tests)
47 public MyCustomRevision(String username) {
48 this.username = username;
52 * WARNING: JPA REQUIRES GETTERS!!!
59 public Date getRevisionDate() {
63 public String getUsername() {
67 public void setUsername(String username) {
68 this.username = username;