From 0d76067e4a778744ad234d240009f0d2910ccdd3 Mon Sep 17 00:00:00 2001 From: peageon Date: Fri, 7 Jun 2024 22:42:59 +0900 Subject: [PATCH] fix: Fixed Builder pattern ignoring initialization of OneToMany variable with empty list --- src/main/java/com/runningmate/backend/member/Member.java | 2 ++ src/main/java/com/runningmate/backend/posts/Post.java | 1 + 2 files changed, 3 insertions(+) diff --git a/src/main/java/com/runningmate/backend/member/Member.java b/src/main/java/com/runningmate/backend/member/Member.java index 9f32c9c..3d138ce 100644 --- a/src/main/java/com/runningmate/backend/member/Member.java +++ b/src/main/java/com/runningmate/backend/member/Member.java @@ -50,9 +50,11 @@ public class Member { private LocalDateTime modifiedAt; @OneToMany(mappedBy = "follower", cascade = CascadeType.ALL, orphanRemoval = true) + @Builder.Default private List followers = new ArrayList<>(); @OneToMany(mappedBy = "following", cascade = CascadeType.ALL, orphanRemoval = true) + @Builder.Default private List followings = new ArrayList<>(); @PrePersist diff --git a/src/main/java/com/runningmate/backend/posts/Post.java b/src/main/java/com/runningmate/backend/posts/Post.java index a756505..81b7768 100644 --- a/src/main/java/com/runningmate/backend/posts/Post.java +++ b/src/main/java/com/runningmate/backend/posts/Post.java @@ -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 comments = new ArrayList<>(); @CreatedDate