1 package de.spring.example.persistence.domain.audit;
3 import java.time.LocalDateTime;
6 import javax.persistence.Column;
7 import javax.persistence.Entity;
8 import javax.persistence.GeneratedValue;
9 import javax.persistence.GenerationType;
10 import javax.persistence.Id;
11 import javax.persistence.Table;
12 import javax.persistence.Temporal;
13 import javax.persistence.TemporalType;
15 /** import org.hibernate.envers.DefaultRevisionEntity; **/
16 import org.hibernate.envers.RevisionEntity;
17 import org.hibernate.envers.RevisionNumber;
18 import org.hibernate.envers.RevisionTimestamp;
21 @RevisionEntity(MyCustomRevisionListener.class)
22 @Table(name="CUSTOM_REVISION", schema="mybatis_example")
23 public class MyCustomRevision /** extends DefaultRevisionEntity **/ {
26 @GeneratedValue(strategy=GenerationType.IDENTITY)
27 @Column(name="ID", updatable=false, nullable=false)
31 @Column(name="REVISION_DATE")
32 @Temporal(TemporalType.TIMESTAMP)
34 private Date revisionDate;
36 @Column(name="USERNAME")
37 private String username;
39 // It will be used by JPA when filling the property fields with data coming from data base.
40 protected MyCustomRevision() {
44 // It will be used by my code (for example by Unit Tests)
45 public MyCustomRevision(String username) {
46 this.username = username;
50 * WARNING: JPA REQUIRES GETTERS!!!
57 public Date getRevisionDate() {
61 public String getUsername() {
65 public void setUsername(String username) {
66 this.username = username;