-
Notifications
You must be signed in to change notification settings - Fork 1
fix: 조회 API N+1 쿼리 및 트랜잭션 오버헤드 제거(eliminate N+1 queries and implicit transaction overhead in schedule inquiry API) #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2bda61c
1732d9e
ea60cb9
98a836a
972feff
cb8bcda
f04c27a
272f0ba
15b226c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.slam.concertreservation.domain.concert.model; | ||
|
|
||
| /** | ||
| * 예약 가능 공연 일정 조회 시 반환되는 공연 일정 & 공연 정보 조합 모델 | ||
| * @param concertSchedule | ||
| * @param concert | ||
| */ | ||
| public record ConcertScheduleWithConcert( | ||
| ConcertSchedule concertSchedule, | ||
| Concert concert | ||
| ) {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,14 @@ | ||
| package com.slam.concertreservation.domain.concert.repository; | ||
|
|
||
| import com.slam.concertreservation.domain.concert.model.Concert; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
||
| public interface ConcertRepository { | ||
|
|
||
| Concert save(Concert concert); | ||
|
|
||
| Optional<Concert> findById(Long id); | ||
|
|
||
| List<Concert> findAllById(List<Long> ids); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| import com.slam.concertreservation.domain.concert.repository.ConcertRepository; | ||
| import com.slam.concertreservation.infrastructure.persistence.jpa.ConcertJpaRepository; | ||
| import com.slam.concertreservation.infrastructure.persistence.jpa.entities.ConcertJpaEntity; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
@@ -25,4 +26,12 @@ public Optional<Concert> findById(Long concertId) { | |
| return concertJpaRepository.findById(concertId) | ||
| .map(ConcertJpaEntity::toDomain); | ||
| } | ||
|
|
||
| @Override | ||
| public List<Concert> findAllById(List<Long> ids) { | ||
| return concertJpaRepository.findAllById(ids) | ||
| .stream() | ||
| .map(ConcertJpaEntity::toDomain) | ||
| .toList(); | ||
| } | ||
|
Comment on lines
+30
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: rg -n -A 30 'getAvailableConcertScheduleWithConcert' --type=java -g '!*Test*'Repository: leonroars/slam Length of output: 7769 🏁 Script executed: rg -n 'class ConcertScheduleWithConcert' --type=java -A 15Repository: leonroars/slam Length of output: 40 🏁 Script executed: rg -n 'ConcertScheduleWithConcert' --type=java | head -20Repository: leonroars/slam Length of output: 2909 🏁 Script executed: cat -n src/main/java/com/slam/concertreservation/domain/concert/model/ConcertScheduleWithConcert.javaRepository: leonroars/slam Length of output: 402 🏁 Script executed: rg -n -B 5 -A 10 'getAvailableConcertSchedulesWithConcert' src/main/java/com/slam/concertreservation/interfaces/ConcertReservationController.javaRepository: leonroars/slam Length of output: 694 🏁 Script executed: rg -n -B 3 -A 15 'class ConcertScheduleResponse' --type=java -g '!*Test*' | head -50Repository: leonroars/slam Length of output: 2441
Spring Data JPA's Either validate that all Concert IDs exist before creating results, or filter out schedules with missing concerts. 🤖 Prompt for AI Agents |
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.