Skip to content

[FIX] 쿼리 타입 정합성을 Long을 값 비교로 수정, 미션 단건 조회시 요청자 이름 추가 - #133

Merged
goodjunseon merged 2 commits into
devfrom
fix/132
Jan 19, 2026
Merged

[FIX] 쿼리 타입 정합성을 Long을 값 비교로 수정, 미션 단건 조회시 요청자 이름 추가#133
goodjunseon merged 2 commits into
devfrom
fix/132

Conversation

@goodjunseon

@goodjunseon goodjunseon commented Jan 19, 2026

Copy link
Copy Markdown
Member

1. 한줄 요약 (What / Why)

  • What: 미션 단건 조회 응답에 요청자 닉네임을 추가하고, FamilyRelation 자녀 조회 JPQL을 parentId.value 비교로 수정했습니다.
  • Why: 미션 상세 소비자에게 요청자 정보를 제공하고, 임베디드 ID와 Long 비교 시 발생할 수 있는 타입 불일치를 해소해 조회 안정성을 높이기 위함입니다.

2. 리뷰 포인트 (최대 3개)

  1. 미션 상세 응답 스키마 확장이 기존 클라이언트/계약에 미치는 영향
  2. 요청자 닉네임 조회 추가에 따른 DB 접근 1회 증가가 성능/N+1 측면에서 허용 가능한지
  3. parentId.value 직접 비교가 다른 FamilyRelation 조회 경로와 매핑 일관성을 유지하는지

3. 테스트 방법 (간단히)

  • ./gradlew test
  • GET /api/missions/{missionId} (응답에 requesterNickname 포함 확인)

4) 리스크/주의사항 (있으면)

  • 미션 상세 API 응답 필드 확장으로 클라이언트 파싱 수정 필요
  • 요청자 닉네임 조회 추가로 DB 호출 1회 증가 (성능 영향 점검 필요)

🔗 Relation Issue

@goodjunseon goodjunseon changed the title [FIX] 쿼리 타입 정합성을 Long을 값 비교로 수정 [FIX] 쿼리 타입 정합성을 Long을 값 비교로 수정, 미션 단건 조회시 요청자 이름 추가 Jan 19, 2026
Copilot AI review requested due to automatic review settings January 19, 2026 05:48
@goodjunseon
goodjunseon merged commit 7b3bcb7 into dev Jan 19, 2026
5 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the mission detail API by adding the requester's nickname to the response and fixes a type mismatch issue in the FamilyRelation JPQL query.

Changes:

  • Added requesterNickname field to MissionDetailResponse to provide complete requester information
  • Fixed JPQL query in FamilyRelationJpaRepository to use parentId.value for proper Long comparison
  • Added requester member lookup in MissionReadService with appropriate error handling

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
MissionDetailResponse.java Added requesterNickname field to the response record and factory method
MissionReadService.java Added requester member lookup and passed requester nickname to response; improved code formatting
FamilyRelationJpaRepository.java Fixed JPQL query to compare parentId.value with Long parameter instead of embedded MemberId object

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +135 to +139
// 수신자, 요청자 닉네임 조회
Member recipient = memberJpaRepository.findById(mission.getRecipientId().getValue())
.orElseThrow(() -> BaseException.from(MissionErrorCode.MEMBER_NOT_FOUND));
Member requester = memberJpaRepository.findById(mission.getRequesterId().getValue())
.orElseThrow(() -> BaseException.from(MissionErrorCode.MEMBER_NOT_FOUND));

Copilot AI Jan 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two sequential database calls are made to fetch recipient and requester members separately. Consider optimizing this by fetching both members in a single query using findAllById method, which would reduce the number of database round trips from 2 to 1.

Suggested change
// 수신자, 요청자 닉네임 조회
Member recipient = memberJpaRepository.findById(mission.getRecipientId().getValue())
.orElseThrow(() -> BaseException.from(MissionErrorCode.MEMBER_NOT_FOUND));
Member requester = memberJpaRepository.findById(mission.getRequesterId().getValue())
.orElseThrow(() -> BaseException.from(MissionErrorCode.MEMBER_NOT_FOUND));
// 수신자, 요청자 닉네임 조회 - 두 번의 단건 조회 대신 한 번의 다건 조회 사용
Long recipientId = mission.getRecipientId().getValue();
Long requesterId = mission.getRequesterId().getValue();
List<Member> members = memberJpaRepository.findAllById(Arrays.asList(recipientId, requesterId));
java.util.Map<Long, Member> memberMap = members.stream()
.collect(Collectors.toMap(member -> member.getId().getValue(), member -> member));
Member recipient = memberMap.get(recipientId);
if (recipient == null) {
throw BaseException.from(MissionErrorCode.MEMBER_NOT_FOUND);
}
Member requester = memberMap.get(requesterId);
if (requester == null) {
throw BaseException.from(MissionErrorCode.MEMBER_NOT_FOUND);
}

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BugFix] findAllConnectedChildrenByParentId 호출에서 타입 미스매치

3 participants