From e8ea730a5a1b26dce6e49355b9edbd2612daaa6d Mon Sep 17 00:00:00 2001 From: myqewr Date: Sun, 16 Mar 2025 19:14:03 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20JPA=20Entity=EC=99=80=20Postgresql=20enu?= =?UTF-8?q?m=20type=20mapping=20error=20=EC=88=98=EC=A0=95(#21)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ftm/server/entity/entities/BeautyProduct.java | 5 ++++- .../ftm/server/entity/entities/GroomingTestQuestion.java | 5 ++++- .../ftm/server/entity/entities/GroomingTestResult.java | 4 ++-- src/main/java/com/ftm/server/entity/entities/Post.java | 4 ++++ src/main/java/com/ftm/server/entity/entities/User.java | 8 ++++++++ 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/ftm/server/entity/entities/BeautyProduct.java b/src/main/java/com/ftm/server/entity/entities/BeautyProduct.java index c69b96e..5669afb 100644 --- a/src/main/java/com/ftm/server/entity/entities/BeautyProduct.java +++ b/src/main/java/com/ftm/server/entity/entities/BeautyProduct.java @@ -6,6 +6,8 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import org.hibernate.annotations.JdbcTypeCode; +import org.hibernate.type.SqlTypes; @Entity @Table(name = "beauty_product") @@ -21,7 +23,8 @@ public class BeautyProduct extends BaseEntity { private String productImageLink; @Enumerated(EnumType.STRING) - @Column(name = "beauty_product_category") + @JdbcTypeCode(SqlTypes.NAMED_ENUM) + @Column(name = "beauty_product_category", columnDefinition = "beauty_product_category") private BeautyProductCategory beautyProductCategory; private String brand; diff --git a/src/main/java/com/ftm/server/entity/entities/GroomingTestQuestion.java b/src/main/java/com/ftm/server/entity/entities/GroomingTestQuestion.java index feff372..61a2c1c 100644 --- a/src/main/java/com/ftm/server/entity/entities/GroomingTestQuestion.java +++ b/src/main/java/com/ftm/server/entity/entities/GroomingTestQuestion.java @@ -6,6 +6,8 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import org.hibernate.annotations.JdbcTypeCode; +import org.hibernate.type.SqlTypes; @Entity @Table(name = "grooming_test_question") @@ -17,7 +19,8 @@ public class GroomingTestQuestion extends BaseEntity { private Long id; @Enumerated(EnumType.STRING) - @Column(nullable = false) + @JdbcTypeCode(SqlTypes.NAMED_ENUM) + @Column(nullable = false, name = "grooming_category", columnDefinition = "grooming_category") private GroomingCategory groomingCategory; @Column(nullable = false) diff --git a/src/main/java/com/ftm/server/entity/entities/GroomingTestResult.java b/src/main/java/com/ftm/server/entity/entities/GroomingTestResult.java index 619eb52..b9f71d6 100644 --- a/src/main/java/com/ftm/server/entity/entities/GroomingTestResult.java +++ b/src/main/java/com/ftm/server/entity/entities/GroomingTestResult.java @@ -21,11 +21,11 @@ public class GroomingTestResult extends BaseEntity { private User user; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "grommig_test_answer_id") + @JoinColumn(name = "grooming_test_answer_id") private GroomingTestAnswer groomingTestAnswer; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "grommig_test_question_id") + @JoinColumn(name = "grooming_test_question_id") private GroomingTestQuestion groomingTestQuestion; @Builder(access = AccessLevel.PRIVATE) diff --git a/src/main/java/com/ftm/server/entity/entities/Post.java b/src/main/java/com/ftm/server/entity/entities/Post.java index 4dc1f3c..ed7e2fe 100644 --- a/src/main/java/com/ftm/server/entity/entities/Post.java +++ b/src/main/java/com/ftm/server/entity/entities/Post.java @@ -10,7 +10,9 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import org.hibernate.annotations.JdbcTypeCode; import org.hibernate.annotations.Type; +import org.hibernate.type.SqlTypes; @Entity @Table(name = "post") @@ -33,6 +35,8 @@ public class Post extends BaseEntity { private String content; @Enumerated(EnumType.STRING) + @JdbcTypeCode(SqlTypes.NAMED_ENUM) + @Column(nullable = false, name = "grooming_category", columnDefinition = "grooming_category") private GroomingCategory groomingCategory; @Type( diff --git a/src/main/java/com/ftm/server/entity/entities/User.java b/src/main/java/com/ftm/server/entity/entities/User.java index 3684a4e..1c2838a 100644 --- a/src/main/java/com/ftm/server/entity/entities/User.java +++ b/src/main/java/com/ftm/server/entity/entities/User.java @@ -12,7 +12,9 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import org.hibernate.annotations.JdbcTypeCode; import org.hibernate.annotations.Type; +import org.hibernate.type.SqlTypes; @Entity @Table(name = "users") @@ -31,10 +33,14 @@ public class User extends BaseEntity { @Column(nullable = false, unique = true) private String nickname; + @Column(name = "age_group", columnDefinition = "age_group") @Enumerated(EnumType.STRING) + @JdbcTypeCode(SqlTypes.NAMED_ENUM) private AgeGroup ageGroup; @Enumerated(EnumType.STRING) + @JdbcTypeCode(SqlTypes.NAMED_ENUM) + @Column(name = "social_provider", columnDefinition = "social_provider") private SocialProvider socialProvider; @Column(unique = true) @@ -48,6 +54,8 @@ public class User extends BaseEntity { private GroomingLevel groomingLevel; @Enumerated(EnumType.STRING) + @JdbcTypeCode(SqlTypes.NAMED_ENUM) + @Column(name = "role", columnDefinition = "role") private UserRole role; @Type(