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.
🔥Pull requests
👷 과제 구현
필수과제
선택과제
구현한 내용에 대해서 설명해주세요
1. 댓글(Comment) CRUD 기능 구현
엔티티 설계
Comment엔티티 생성API 엔드포인트
POST /api/v1/comments- 댓글 생성GET /api/v1/comments/{id}- 댓글 조회PATCH /api/v1/comments/{id}- 댓글 수정DELETE /api/v1/comments/{id}- 댓글 삭제서비스 로직
2. Article 조회 API 응답 필드 수정
ArticleResponse 구조 변경
comments필드 추가Comment(commentId, memberId, comment)N+1 문제 해결
구현하며 고민했던 내용을 적어주세요 (사소한 것도 좋아요)
JPA에서의 올바른 업데이트 방법
댓글 수정 및 회원 수정 기능을 구현하면서 JPA의 업데이트 메커니즘에 대해 깊이 고민했습니다.
고민한 내용:
변경 감지(Dirty Checking) vs 명시적 save() 호출
save()없이도 자동으로 DB에 반영됩니다업데이트 로직의 위치
update()메서드를 두어 응집도를 높였습니다트랜잭션 범위의 중요성
@Transactional어노테이션이 없으면 변경 감지가 작동하지 않습니다readOnly = true)에서는 변경 감지가 동작하지 않음을 확인했습니다결론
이번 과제에서는 변경 감지(Dirty Checking) 방식을 선택했습니다.
선택 이유
save()호출 제거update()메서드를 두어 응집도 향상