Created
July 2, 2018 08:42
-
-
Save Ikhiloya/4bec0ca0fe59c9d8b177c73e2786ae05 to your computer and use it in GitHub Desktop.
An abstract class that with Jpa Auditing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | |
| import org.springframework.data.annotation.CreatedDate; | |
| import org.springframework.data.annotation.LastModifiedDate; | |
| import org.springframework.data.jpa.domain.support.AuditingEntityListener; | |
| import javax.persistence.*; | |
| import java.io.Serializable; | |
| import java.util.Date; | |
| @MappedSuperclass | |
| @EntityListeners(AuditingEntityListener.class) | |
| @JsonIgnoreProperties( | |
| value = {"createdAt", "updatedAt"}, | |
| allowGetters = true | |
| ) | |
| public abstract class AuditModel implements Serializable { | |
| @Temporal(TemporalType.TIMESTAMP) | |
| @Column(name = "created_at", nullable = false, updatable = false) | |
| @CreatedDate | |
| private Date createdAt; | |
| @Temporal(TemporalType.TIMESTAMP) | |
| @Column(name = "updated_at", nullable = false) | |
| @LastModifiedDate | |
| private Date updatedAt; | |
| public Date getCreatedAt() { | |
| return createdAt; | |
| } | |
| public void setCreatedAt(Date createdAt) { | |
| this.createdAt = createdAt; | |
| } | |
| public Date getUpdatedAt() { | |
| return updatedAt; | |
| } | |
| public void setUpdatedAt(Date updatedAt) { | |
| this.updatedAt = updatedAt; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment