package com.spring.common.jpa;

import java.time.LocalDateTime;

import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;

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

import lombok.Getter;

@Getter
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public abstract class AuditEntity {

    @CreatedDate
    @Column(name = "CREATED_DATE", updatable = false, insertable = true)
    protected LocalDateTime createdDate;

    @CreatedBy
    @Column(name = "CREATED_BY", updatable = false, insertable = true, length = 50)
    protected String createdBy;

    @LastModifiedDate
    @Column(name = "MODIFIED_DATE", updatable = true, insertable = true)
    protected LocalDateTime modifiedDate;

    @LastModifiedBy
    @Column(name = "MODIFIED_BY", updatable = true, insertable = true, length = 50)
    protected String modifiedBy;

}
