File tree Expand file tree Collapse file tree 2 files changed +5
-6
lines changed
Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Original file line number Diff line number Diff line change 1313
1414public interface CheerRepository extends JpaRepository <Cheer , Long > {
1515
16- @ EntityGraph (attributePaths = {"store" , "member" , "cheerTags" })
16+ @ EntityGraph (attributePaths = {"store" , "member" , "cheerTags.values " })
1717 List <Cheer > findAllByOrderByCreatedAtDesc (Pageable pageable );
1818
19- @ EntityGraph (attributePaths = {"member" , "cheerTags" })
20- List <Cheer > findAllByStoreOrderByCreatedAtDesc ( Store store , Pageable pageable );
19+ @ EntityGraph (attributePaths = {"member" , "cheerTags.values " })
20+ List <Cheer > findAllByStoreIdOrderByCreatedAtDesc ( Long storeId , Pageable pageable );
2121
2222 @ Query ("""
2323 SELECT c.imageKey FROM Cheer c
Original file line number Diff line number Diff line change @@ -75,12 +75,11 @@ private CheersResponse toCheersResponse(List<Cheer> cheers) {
7575
7676 @ Transactional (readOnly = true )
7777 public CheersInStoreResponse getCheersByStoreId (Long storeId , int page , int size ) {
78- Store store = storeRepository .getById (storeId );
79- List <Cheer > cheers = cheerRepository .findAllByStoreOrderByCreatedAtDesc (store , PageRequest .of (page , size ));
78+ List <Cheer > cheers = cheerRepository .findAllByStoreIdOrderByCreatedAtDesc (storeId , PageRequest .of (page , size ));
8079
8180 List <CheerInStoreResponse > cheersResponse = cheers .stream ()
8281 .map (CheerInStoreResponse ::new )
83- .toList (); // TODO N+1 문제 해결
82+ .toList ();
8483 return new CheersInStoreResponse (cheersResponse );
8584 }
8685}
You can’t perform that action at this time.
0 commit comments