From c1c0608efab28675debf5c953ab2223367a76b40 Mon Sep 17 00:00:00 2001 From: yooonwodyd Date: Fri, 27 Sep 2024 18:37:46 +0900 Subject: [PATCH] feat:[#24]- Add LocalDateTime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit String으로 관리하던 타입을 LocalDateTime으로 변경 --- .../java/com/helpmeCookies/user/entity/User.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/helpmeCookies/user/entity/User.java b/src/main/java/com/helpmeCookies/user/entity/User.java index fe51ef9..0e5a85f 100644 --- a/src/main/java/com/helpmeCookies/user/entity/User.java +++ b/src/main/java/com/helpmeCookies/user/entity/User.java @@ -1,7 +1,11 @@ package com.helpmeCookies.user.entity; +import java.time.LocalDateTime; import java.util.List; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.format.annotation.DateTimeFormat; + import com.helpmeCookies.product.entity.HashTag; import jakarta.persistence.CollectionTable; @@ -47,9 +51,14 @@ public class User { @Column(nullable = false) private String address; + @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @CreatedDate + @Column(nullable = false, updatable = false) + protected LocalDateTime createdAt; + // 별도의 테이블 생성. 문자열로 저장 @ElementCollection(targetClass = HashTag.class) - @CollectionTable(name = "user_hashtag") + @CollectionTable(name = "user_hashtags") @Enumerated(EnumType.STRING) - private List hashTags; -} + private List hashTags; // 기본 FetchType.LAZY +} \ No newline at end of file