create용 기본엔티티, create/update까지 있는 엔티티로 구분하여 커밋하기

This commit is contained in:
2025-11-18 12:16:25 +09:00
parent 4e489b7333
commit af4fe2b2ed
2 changed files with 24 additions and 1 deletions

View File

@@ -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();
}
}

View File

@@ -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