From af4fe2b2ed10a9a7d3c9acee6269150716be37f5 Mon Sep 17 00:00:00 2001 From: "gayoun.park" Date: Tue, 18 Nov 2025 12:16:25 +0900 Subject: [PATCH] =?UTF-8?q?create=EC=9A=A9=20=EA=B8=B0=EB=B3=B8=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0,=20create/update=EA=B9=8C=EC=A7=80=20?= =?UTF-8?q?=EC=9E=88=EB=8A=94=20=EC=97=94=ED=8B=B0=ED=8B=B0=EB=A1=9C=20?= =?UTF-8?q?=EA=B5=AC=EB=B6=84=ED=95=98=EC=97=AC=20=EC=BB=A4=EB=B0=8B?= =?UTF-8?q?=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../postgres/CommonCreateEntity.java | 23 +++++++++++++++++++ .../kamcoback/postgres/CommonDateEntity.java | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/kamco/cd/kamcoback/postgres/CommonCreateEntity.java diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/CommonCreateEntity.java b/src/main/java/com/kamco/cd/kamcoback/postgres/CommonCreateEntity.java new file mode 100644 index 00000000..e0950848 --- /dev/null +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/CommonCreateEntity.java @@ -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(); + } +} diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/CommonDateEntity.java b/src/main/java/com/kamco/cd/kamcoback/postgres/CommonDateEntity.java index 195b182d..b10e54c0 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/CommonDateEntity.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/CommonDateEntity.java @@ -18,7 +18,7 @@ public class CommonDateEntity { private ZonedDateTime createdDate; @LastModifiedDate - @Column(name = "updated_dttm", nullable = true) //update_dttm 이 없는 테이블이 존재하기 때문에 true 로 선언함 + @Column(name = "updated_dttm", nullable = false) private ZonedDateTime modifiedDate; @PrePersist