Skip to content

Commit

Permalink
fix: Fixed Builder pattern ignoring initialization of OneToMany varia…
Browse files Browse the repository at this point in the history
…ble with empty list
  • Loading branch information
peageon committed Jun 7, 2024
1 parent 105e1e4 commit 0d76067
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/runningmate/backend/member/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ public class Member {
private LocalDateTime modifiedAt;

@OneToMany(mappedBy = "follower", cascade = CascadeType.ALL, orphanRemoval = true)
@Builder.Default
private List<Follow> followers = new ArrayList<>();

@OneToMany(mappedBy = "following", cascade = CascadeType.ALL, orphanRemoval = true)
@Builder.Default
private List<Follow> followings = new ArrayList<>();

@PrePersist
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/runningmate/backend/posts/Post.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class Post {

@OneToMany(mappedBy = "post", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@OrderBy("createdAt asc") //Order by time, 시간 순으로 정렬
@Builder.Default
private List<Comment> comments = new ArrayList<>();

@CreatedDate
Expand Down

0 comments on commit 0d76067

Please sign in to comment.