package sg.ncl.testbed_interface.repositories.jpa.entities;

import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;
import java.time.ZonedDateTime;

/**
 * @author Christopher Zhong
 */
@MappedSuperclass
@EntityListeners({AuditingEntityListener.class})
public class AbstractEntity {

//    @Column(name = "created_by")
//    @CreatedBy
//    private String createdBy;

    @Column(name = "created_date", nullable = false)
    @CreatedDate
    private ZonedDateTime createdDate;

//    @Column(name = "last_modified_by")
//    @LastModifiedBy
//    private String lastModifiedBy;

    @Column(name = "last_modified_date", nullable = false)
    @LastModifiedDate
    private ZonedDateTime lastModifiedDate;

    public ZonedDateTime getCreatedDate() {
        return createdDate;
    }

    public ZonedDateTime getLastModifiedDate() {
        return lastModifiedDate;
    }

}

@@ -365,16 +365,50 @@
 rclass;%0A
+import javax.persistence.Version;%0A
 import j
@@ -997,163 +997,661 @@
     
-public ZonedDateTime getCreatedDate() %7B%0A        return createdDate;%0A    %7D%0A%0A    public ZonedDateTime getLastModifiedDate() %7B%0A        return lastModifiedDate
+@Version%0A    @Column(name = %22version%22, nullable = false)%0A    private Long version = 0L;%0A%0A    public ZonedDateTime getCreatedDate() %7B%0A        return createdDate;%0A    %7D%0A%0A    protected void setCreatedDate(final ZonedDateTime createdDate) %7B%0A        this.createdDate = createdDate;%0A    %7D%0A%0A    public ZonedDateTime getLastModifiedDate() %7B%0A        return lastModifiedDate;%0A    %7D%0A%0A    protected void setLastModifiedDate(final ZonedDateTime lastModifiedDate) %7B%0A        this.lastModifiedDate = lastModifiedDate;%0A    %7D%0A%0A    public Long getVersion() %7B%0A        return version;%0A    %7D%0A%0A    protected void setVersion(final Long version) %7B%0A        this.version = version
 ;%0A  

Add versioning to JPA entities (DEV-15)