Skip to content

Commit

Permalink
fix: Entity Id는 생성자에서 제외
Browse files Browse the repository at this point in the history
  • Loading branch information
gusah009 committed Aug 27, 2023
1 parent 3e62716 commit 508d204
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 508d204

Please sign in to comment.