Spring JPA: no time for comments
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Wed, 20 Jul 2016 21:05:19 +0000 (23:05 +0200)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Wed, 20 Jul 2016 21:05:19 +0000 (23:05 +0200)
SpringJava/JPA/spring-jpa-persistence/src/main/java/de/spring/example/persistence/domain/audit/MyCustomRevision.java
SpringJava/JPA/spring-jpa-persistence/src/main/resources/spring-configuration/jpa-configuration.xml

index 692acb5..4febc39 100644 (file)
@@ -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;
     }
index b460a27..6b9ae69 100644 (file)
@@ -30,7 +30,7 @@
                <property name="jpaProperties">\r
                <props>\r
                        <!--\r
-               <prop key="hibernate.hbm2ddl.auto">create-drop</prop>\r
+               <prop key="hibernate.hbm2ddl.auto">create</prop>\r
                -->\r
                <prop key="org.hibernate.envers.audit_table_suffix">_AUDITED</prop>\r
                <prop key="org.hibernate.envers.revision_field_name">REVISION</prop>\r