diff --git a/src/main/java/com/potatocake/everymoment/entity/Diary.java b/src/main/java/com/potatocake/everymoment/entity/Diary.java index c60f671..0071b39 100644 --- a/src/main/java/com/potatocake/everymoment/entity/Diary.java +++ b/src/main/java/com/potatocake/everymoment/entity/Diary.java @@ -1,6 +1,5 @@ package com.potatocake.everymoment.entity; -import jakarta.persistence.CascadeType; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; @@ -57,7 +56,7 @@ public class Diary extends BaseTimeEntity { @Builder.Default private boolean isPublic = false; - @OneToMany(mappedBy = "diary", cascade = CascadeType.ALL, orphanRemoval = true) + @OneToMany(mappedBy = "diary") private Set diaryCategories = new HashSet<>(); public void updateContent(String content) { diff --git a/src/main/java/com/potatocake/everymoment/service/FriendDiaryService.java b/src/main/java/com/potatocake/everymoment/service/FriendDiaryService.java index 2afa0a4..2d6ad53 100644 --- a/src/main/java/com/potatocake/everymoment/service/FriendDiaryService.java +++ b/src/main/java/com/potatocake/everymoment/service/FriendDiaryService.java @@ -47,7 +47,7 @@ public FriendDiariesResponse getFriendDiaries(Long memberId, DiaryFilterRequest List friends = friendRepository.findFriendsByMember(currentMember); List friendIdList = friends.stream() - .map(Friend::getId) + .map(friend -> friend.getFriend().getId()) .collect(Collectors.toList()); Page diaryPage; @@ -64,7 +64,7 @@ public FriendDiariesResponse getFriendDiaries(Long memberId, DiaryFilterRequest diaryFilterRequest.getFrom(), diaryFilterRequest.getUntil(), diaryFilterRequest.getIsBookmark()) - .and((root, query, builder) -> root.get("member").in(friendIdList)); + .and((root, query, builder) -> root.get("member").get("id").in(friendIdList)); diaryPage = diaryRepository.findAll(spec, PageRequest.of(diaryFilterRequest.getKey(), diaryFilterRequest.getSize())); @@ -92,10 +92,10 @@ public FriendDiaryResponse getFriendDiary(Long memberId, Long diaryId) { List friends = friendRepository.findFriendsByMember(currentMember); List friendIdList = friends.stream() - .map(Friend::getId) + .map(friend -> friend.getFriend().getId()) .collect(Collectors.toList()); - if (!friendIdList.contains(diary.getMember())) { + if (!friendIdList.contains(diary.getMember().getId())) { throw new GlobalException(ErrorCode.FRIEND_NOT_FOUND); } @@ -151,4 +151,5 @@ private FriendDiarySimpleResponse convertToFriendDiariesResponseDTO(Diary savedD .createAt(savedDiary.getCreateAt()) .build(); } + }