Skip to content

Commit 0821019

Browse files
committed
[Refactor]: cascade, orphanRemoval 옵션을 통해 투표 게시글 삭제 시 투표 정보 삭제되도록 변경
1 parent 61f2f6e commit 0821019

File tree

1 file changed

+5
-0
lines changed
  • back/src/main/java/com/back/domain/post/entity

1 file changed

+5
-0
lines changed

back/src/main/java/com/back/domain/post/entity/Post.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.back.domain.post.entity;
22

33
import com.back.domain.comment.entity.Comment;
4+
import com.back.domain.poll.entity.PollVote;
45
import com.back.domain.post.enums.PostCategory;
56
import com.back.domain.user.entity.User;
67
import com.back.global.baseentity.BaseEntity;
@@ -64,6 +65,10 @@ public class Post extends BaseEntity {
6465
@Builder.Default
6566
private List<Comment> comments = new ArrayList<>();
6667

68+
@OneToMany(mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true)
69+
@Builder.Default
70+
private List<PollVote> pollVotes = new ArrayList<>();
71+
6772
public void updatePost(String title, String content, PostCategory category) {
6873
this.title = title;
6974
this.content = content;

0 commit comments

Comments
 (0)