create용 기본엔티티, create/update까지 있는 엔티티로 구분하여 커밋하기
This commit is contained in:
@@ -0,0 +1,23 @@
|
|||||||
|
package com.kamco.cd.kamcoback.postgres;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.MappedSuperclass;
|
||||||
|
import jakarta.persistence.PrePersist;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.springframework.data.annotation.CreatedDate;
|
||||||
|
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@MappedSuperclass
|
||||||
|
public class CommonCreateEntity {
|
||||||
|
|
||||||
|
@CreatedDate
|
||||||
|
@Column(name = "created_dttm", updatable = false, nullable = false)
|
||||||
|
private ZonedDateTime createdDate;
|
||||||
|
|
||||||
|
@PrePersist
|
||||||
|
protected void onPersist() {
|
||||||
|
this.createdDate = ZonedDateTime.now();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,7 +18,7 @@ public class CommonDateEntity {
|
|||||||
private ZonedDateTime createdDate;
|
private ZonedDateTime createdDate;
|
||||||
|
|
||||||
@LastModifiedDate
|
@LastModifiedDate
|
||||||
@Column(name = "updated_dttm", nullable = true) //update_dttm 이 없는 테이블이 존재하기 때문에 true 로 선언함
|
@Column(name = "updated_dttm", nullable = false)
|
||||||
private ZonedDateTime modifiedDate;
|
private ZonedDateTime modifiedDate;
|
||||||
|
|
||||||
@PrePersist
|
@PrePersist
|
||||||
|
|||||||
Reference in New Issue
Block a user