Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into feat/#482
Browse files Browse the repository at this point in the history
  • Loading branch information
seokjin8678 committed Nov 14, 2023
2 parents 14fb125 + 1eeb1c7 commit 214ad09
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ private Stage findStageById(Long stageId) {

@Transactional(readOnly = true)
public StageTicketsResponse findStageTickets(Long stageId) {
return StageTicketsResponse.from(ticketRepository.findAllByStageId(stageId));
return StageTicketsResponse.from(ticketRepository.findAllByStageIdWithFetch(stageId));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@

public interface TicketRepository extends JpaRepository<Ticket, Long> {

List<Ticket> findAllByStageId(Long stageId);
@Query("""
SELECT t from Ticket t
INNER JOIN FETCH t.ticketAmount
WHERE t.stage.id = :stageId
""")
List<Ticket> findAllByStageIdWithFetch(@Param("stageId") Long stageId);

Optional<Ticket> findByTicketTypeAndStage(TicketType ticketType, Stage stage);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class TicketServiceTest {
TicketFixture.ticket().id(1L).ticketType(TicketType.STUDENT).stage(stage).build(),
TicketFixture.ticket().id(2L).ticketType(TicketType.VISITOR).stage(stage).build()
);
given(ticketRepository.findAllByStageId(stageId))
given(ticketRepository.findAllByStageIdWithFetch(stageId))
.willReturn(tickets);

// when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class TicketRepositoryTest {
ticketRepository.save(TicketFixture.ticket().stage(otherStage).build());

// when
List<Ticket> actual = ticketRepository.findAllByStageId(stage.getId());
List<Ticket> actual = ticketRepository.findAllByStageIdWithFetch(stage.getId());

// then
assertThat(actual).hasSize(2);
Expand Down

0 comments on commit 214ad09

Please sign in to comment.