From: Gustavo Martin Morcuende Date: Wed, 20 Jul 2016 21:05:19 +0000 (+0200) Subject: Spring JPA: no time for comments X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=4bf3c69551282049cee218c85403e218a4fb12fc;p=JavaForFun Spring JPA: no time for comments --- diff --git a/SpringJava/JPA/spring-jpa-persistence/src/main/java/de/spring/example/persistence/domain/audit/MyCustomRevision.java b/SpringJava/JPA/spring-jpa-persistence/src/main/java/de/spring/example/persistence/domain/audit/MyCustomRevision.java index 692acb5..4febc39 100644 --- a/SpringJava/JPA/spring-jpa-persistence/src/main/java/de/spring/example/persistence/domain/audit/MyCustomRevision.java +++ b/SpringJava/JPA/spring-jpa-persistence/src/main/java/de/spring/example/persistence/domain/audit/MyCustomRevision.java @@ -1,16 +1,37 @@ package de.spring.example.persistence.domain.audit; +import java.time.LocalDateTime; + import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; import org.hibernate.envers.DefaultRevisionEntity; import org.hibernate.envers.RevisionEntity; +import org.hibernate.envers.RevisionNumber; +import org.hibernate.envers.RevisionTimestamp; @Entity @RevisionEntity(MyCustomRevisionListener.class) @Table(name="CUSTOM_REVISION", schema="mybatis_example") public class MyCustomRevision extends DefaultRevisionEntity { + + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + @Column(name="ID", updatable=false, nullable=false) + @RevisionNumber + private Long id; + + @Column(name="REVISION_DATE") + @Temporal(TemporalType.TIMESTAMP) + @RevisionTimestamp + private LocalDateTime revisionDate; + @Column(name="USERNAME") private String username; @@ -28,6 +49,14 @@ public class MyCustomRevision extends DefaultRevisionEntity { * WARNING: JPA REQUIRES GETTERS!!! */ + public Long getId() { + return id; + } + + public LocalDateTime getRevisionDate() { + return revisionDate; + } + public String getUsername() { return username; } diff --git a/SpringJava/JPA/spring-jpa-persistence/src/main/resources/spring-configuration/jpa-configuration.xml b/SpringJava/JPA/spring-jpa-persistence/src/main/resources/spring-configuration/jpa-configuration.xml index b460a27..6b9ae69 100644 --- a/SpringJava/JPA/spring-jpa-persistence/src/main/resources/spring-configuration/jpa-configuration.xml +++ b/SpringJava/JPA/spring-jpa-persistence/src/main/resources/spring-configuration/jpa-configuration.xml @@ -30,7 +30,7 @@ _AUDITED REVISION