From 508d2045c351a7794f77e5c6045d9fb8e1834757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=ED=95=B8=EB=AA=A8?= Date: Sun, 27 Aug 2023 20:10:23 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20Entity=20Id=EB=8A=94=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=EC=9E=90=EC=97=90=EC=84=9C=20=EC=A0=9C=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../joryu/sns_service/comment/entity/Comment.kt | 11 +++++------ .../joryu/sns_service/comment/entity/CommentLike.kt | 11 +++++------ .../main/kotlin/joryu/sns_service/feed/entity/Feed.kt | 11 +++++------ .../kotlin/joryu/sns_service/feed/entity/FeedLike.kt | 11 +++++------ .../kotlin/joryu/sns_service/feed/entity/Share.kt | 11 +++++------ 5 files changed, 25 insertions(+), 30 deletions(-) diff --git a/sns_service/src/main/kotlin/joryu/sns_service/comment/entity/Comment.kt b/sns_service/src/main/kotlin/joryu/sns_service/comment/entity/Comment.kt index f1e79f8..9a1a984 100644 --- a/sns_service/src/main/kotlin/joryu/sns_service/comment/entity/Comment.kt +++ b/sns_service/src/main/kotlin/joryu/sns_service/comment/entity/Comment.kt @@ -15,10 +15,6 @@ import joryu.sns_service.common.entity.BaseEntity @Table(name = "comment") @Entity class Comment( - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - val id: Long, - @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "feed_id", nullable = false) val feed: Feed, @@ -29,8 +25,11 @@ class Comment( content: String, ) : BaseEntity() { - constructor() : this(0, Feed(), null, "") - constructor(feed: Feed, parent: Comment) : this(0, feed, parent, "") + constructor() : this(Feed(), null, "") + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + val id: Long = 0 @Column(name = "content", nullable = false, length = 1000) var content: String = content diff --git a/sns_service/src/main/kotlin/joryu/sns_service/comment/entity/CommentLike.kt b/sns_service/src/main/kotlin/joryu/sns_service/comment/entity/CommentLike.kt index 683df68..6d3dced 100644 --- a/sns_service/src/main/kotlin/joryu/sns_service/comment/entity/CommentLike.kt +++ b/sns_service/src/main/kotlin/joryu/sns_service/comment/entity/CommentLike.kt @@ -14,10 +14,6 @@ import joryu.sns_service.profile.entity.Profile @Table(name = "comment_like") @Entity class CommentLike( - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - val id: Long, - @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "profile_id", nullable = false) val likeMember: Profile, @@ -26,6 +22,9 @@ class CommentLike( @JoinColumn(name = "comment_id", nullable = false) val comment: Comment, ) : BaseEntity() { - constructor() : this(0, Profile(), Comment()) - constructor(likeMember: Profile, comment: Comment) : this(0, likeMember, comment) + constructor() : this(Profile(), Comment()) + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + val id: Long = 0 } diff --git a/sns_service/src/main/kotlin/joryu/sns_service/feed/entity/Feed.kt b/sns_service/src/main/kotlin/joryu/sns_service/feed/entity/Feed.kt index 9cd0e97..4ad4d9f 100644 --- a/sns_service/src/main/kotlin/joryu/sns_service/feed/entity/Feed.kt +++ b/sns_service/src/main/kotlin/joryu/sns_service/feed/entity/Feed.kt @@ -11,14 +11,13 @@ import joryu.sns_service.common.entity.BaseEntity @Table(name = "feed") @Entity class Feed( - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - val id: Long, - content: String, ) : BaseEntity() { - constructor() : this(0, "") - constructor(content: String) : this(0, content) + constructor() : this("") + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + val id: Long = 0 @Column(name = "view_count", nullable = false) var viewCount: Long = 0 diff --git a/sns_service/src/main/kotlin/joryu/sns_service/feed/entity/FeedLike.kt b/sns_service/src/main/kotlin/joryu/sns_service/feed/entity/FeedLike.kt index 14d7b2d..e107728 100644 --- a/sns_service/src/main/kotlin/joryu/sns_service/feed/entity/FeedLike.kt +++ b/sns_service/src/main/kotlin/joryu/sns_service/feed/entity/FeedLike.kt @@ -14,10 +14,6 @@ import joryu.sns_service.profile.entity.Profile @Table(name = "feed_like") @Entity class FeedLike( - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - val id: Long, - @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "profile_id", nullable = false) val likeMember: Profile, @@ -26,6 +22,9 @@ class FeedLike( @JoinColumn(name = "feed_id", nullable = false) val feed: Feed, ) : BaseEntity() { - constructor() : this(0, Profile(), Feed()) - constructor(likeMember: Profile, feed: Feed) : this(0, likeMember, feed) + constructor() : this(Profile(), Feed()) + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + val id: Long = 0 } diff --git a/sns_service/src/main/kotlin/joryu/sns_service/feed/entity/Share.kt b/sns_service/src/main/kotlin/joryu/sns_service/feed/entity/Share.kt index 408e550..6eb85d0 100644 --- a/sns_service/src/main/kotlin/joryu/sns_service/feed/entity/Share.kt +++ b/sns_service/src/main/kotlin/joryu/sns_service/feed/entity/Share.kt @@ -13,14 +13,13 @@ import joryu.sns_service.common.entity.BaseEntity @Table(name = "share") @Entity class Share( - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - val id: Long, - @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "feed_id", nullable = false) val feed: Feed, ) : BaseEntity() { - constructor() : this(0, Feed()) - constructor(feed: Feed) : this(0, feed) + constructor() : this(Feed()) + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + val id: Long = 0 }