Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 본 PR은 위키 시스템에서 전체 문서의 제목과 UUID 목록을 효율적으로 가져오기 위한 API 기능을 구현합니다. 기존의 전체 문서 조회 방식과 달리 필요한 필드만 선택적으로 조회하도록 쿼리를 최적화하였으며, 관련 서비스 로직과 테스트 코드를 포함하여 안정성을 확보했습니다. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new endpoint and service method to retrieve all wiki document titles and their UUIDs. The feedback suggests improving the JPQL query by avoiding hardcoded DTO projection paths, removing a redundant @Transactional(readOnly = true) annotation from the service method, and using the static import assertThat in the test class for consistency.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| @Query(""" | ||
| SELECT new com.wooteco.wiki.document.domain.dto.DocumentTitleListResponse(d.title, d.uuid) | ||
| FROM Document d | ||
| ORDER BY d.title | ||
| """) | ||
| List<DocumentTitleListResponse> findAllTitles(); |
There was a problem hiding this comment.
JPQL 쿼리 내에 DTO의 전체 패키지 경로(com.wooteco.wiki.document.domain.dto.DocumentTitleListResponse)를 하드코딩하는 DTO 프로젝션 방식은 리팩터링 시 패키지 경로가 변경되면 쿼리 문자열을 직접 수정해야 하므로 유지보수성이 떨어집니다.
N+1 쿼리 문제를 해결하기 위해 DTO 프로젝션 대신 fetch join을 사용하는 것을 권장합니다. fetch join은 DTO 패키지 경로를 하드코딩하지 않고도 타입 안정성을 제공하여 유지보수성을 높일 수 있습니다.
References
- To resolve N+1 query problems, prefer using a fetch join over DTO projection. DTO projection can introduce maintenance issues by hardcoding DTO package paths in JPQL queries, making refactoring difficult. Fetch join provides a type-safe alternative without this drawback.
| @Transactional(readOnly = true) | ||
| public List<DocumentTitleListResponse> findAllTitles() { | ||
| return documentRepository.findAllTitles(); | ||
| } |
There was a problem hiding this comment.
There was a problem hiding this comment.
반영했습니다.
추가적으로 기존 전체 문서 조회(Pageable) API (GET {{BASE_URL}}/document) 메서드에서도 같은 문제가 존재합니다.
@RequiredArgsConstructor
@Transactional(readOnly = true)
@Service
public class DocumentService {
private final DocumentRepository documentRepository;
@Transactional(readOnly = true)
public Page<Document> findAll(PagingRequest pagingRequest) {
return documentRepository.findAll(pagingRequest.toPageable());
}
public List<DocumentTitleListResponse> findAllTitles() {
return documentRepository.findAllTitles();
}| List<DocumentTitleListResponse> result = documentService.findAllTitles(); | ||
|
|
||
| // then | ||
| Assertions.assertThat(result).isEmpty(); |
관련 이슈
작업 내용
GET /document/titlestitle,uuid만 반환하는DocumentTitleListResponse추가title,uuid만 조회