[Issue] 매거진 댓글 작성자가 수정, 삭제를 못하는 에러 해결 #168
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📝 작업 내용
댓글 작성자인데 댓글 수정,삭제 시 요청이 처리가 되지 않는 문제를 해결했습니다.
문제되는 부분
isCommentAuthor 메서드는 두 객체의 참조값을 비교연산해 동일한 작성자인지를 체크하고 있었습니다.
하지만 MagazineComment의 Member 인스턴스는 실제로 LazyLoading 으로 인한 Proxy 객체 이므로 동일 비교 시 논리적으론 두 객체가 동일하지만 참조값이 달라서 문제가 발생했습니다.
따라서 이를 해결하기위해 equals 메서드를 재정의하였고 Primary Key 필드를 통해서 동등성 비교를 하도록 로직을 개선했습니다.
🦾 연관된 이슈
https://mediaxi.atlassian.net/browse/ART-188?atlOrigin=eyJpIjoiMzliOGZlMTZlNWZmNDdmNWE1NmZlYmYyMWM2YjE2OTUiLCJwIjoiaiJ9
💬리뷰 요구사항