package io.smsc.model;

import com.fasterxml.jackson.annotation.*;
import org.springframework.data.annotation.LastModifiedDate;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * Specifies Base entity class as an mapped superclass. It's mapping information
 * is applied to the entities that inherit from it. It contains only id property
 * and equals/hashcode implementations.
 *
 * @author Nazar Lipkovskyy
 * @see MappedSuperclass
 * @since 0.0.1-SNAPSHOT
 */
@MappedSuperclass
@Access(AccessType.FIELD)
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler"}, ignoreUnknown = true)
public abstract class BaseEntity implements Serializable {

    protected static final long serialVersionUID = 1L;

    @LastModifiedDate
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "LAST_MODIFIED_DATE", nullable = false)
    @JsonIgnore
    protected Date lastModifiedDate = new Date();

    @Version
    @Column(name = "VERSION", nullable = false)
    @JsonIgnore
    protected Long version;

    @PreUpdate
    protected void onUpdate() {
        lastModifiedDate = new Date();
    }

    @JsonProperty
    public Long getVersion() {
        return version;
    }

    @JsonIgnore
    public void setVersion(Long versionNumber) {
        this.version = versionNumber;
    }

    @JsonProperty
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "UTC")
    public Date getLastModifiedDate() {
        return lastModifiedDate;
    }

    @JsonIgnore
    public void setLastModifiedDate(Date lastModifiedDate) {
        this.lastModifiedDate = lastModifiedDate;
    }

    @Override
    public String toString() {
        return "{lastModifiedDate=" + lastModifiedDate +
                ", version=" + version +
                '}';
    }
}

@@ -103,32 +103,17 @@
 otation.
-LastModifiedDate
+*
 ;%0A%0Aimpor
@@ -131,24 +131,61 @@
 sistence.*;%0A
+import javax.persistence.AccessType;%0A
 import java.
@@ -959,21 +959,8 @@
 );%0A%0A
-    @Version%0A
     
@@ -1045,16 +1045,21 @@
  version
+ = 0L
 ;%0A%0A    @
@@ -1139,16 +1139,45 @@
 Date();%0A
+        version = ++version;%0A
     %7D%0A%0A 
@@ -1636,24 +1636,24 @@
 fiedDate) %7B%0A
+
         this
@@ -1699,178 +1699,7 @@
    %7D
-%0A%0A    @Override%0A    public String toString() %7B%0A        return %22%7BlastModifiedDate=%22 + lastModifiedDate +%0A                %22, version=%22 + version +%0A                '%7D';%0A    %7D
 %0A%7D%0A

Remove @Version annotation from VERSION column (it prevented 'version' column to be exported, etag header is creating without annotation)