1 package de.spring.example.persistence.domain.audit;
3 import java.time.LocalDateTime;
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;
20 @RevisionEntity(MyCustomRevisionListener.class)
21 @Table(name="CUSTOM_REVISION", schema="mybatis_example")
22 public class MyCustomRevision extends DefaultRevisionEntity {
25 @GeneratedValue(strategy=GenerationType.IDENTITY)
26 @Column(name="ID", updatable=false, nullable=false)
30 @Column(name="REVISION_DATE")
31 @Temporal(TemporalType.TIMESTAMP)
33 private LocalDateTime revisionDate;
35 @Column(name="USERNAME")
36 private String username;
38 // It will be used by JPA when filling the property fields with data coming from data base.
39 protected MyCustomRevision() {
43 // It will be used by my code (for example by Unit Tests)
44 public MyCustomRevision(String username) {
45 this.username = username;
49 * WARNING: JPA REQUIRES GETTERS!!!
56 public LocalDateTime getRevisionDate() {
60 public String getUsername() {
64 public void setUsername(String username) {
65 this.username = username;