Skip to content

Commit

Permalink
Fix: n+1 problem solved and boardview listing order reversed
Browse files Browse the repository at this point in the history
  • Loading branch information
resource777 committed Nov 3, 2023
1 parent 6d8b4d7 commit d8b727a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.webtoonchat.toonchat.domain.board.entity.Board;



public interface BoardRepository extends JpaRepository<Board, Long> {
List<Board> findAllByCharacterId(Long characterId);
@Query("select b "
+ "from Board b left join fetch b.comments c left join fetch c.member "
+ "where b.characterId=:characterId order by b.id desc")
List<Board> findAllByCharacterIdOrderByIdDesc(Long characterId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public List<Board> findAll() {


public List<Board> findAllByCharacterId(Long characterId) {
return boardRepository.findAllByCharacterId(characterId);
return boardRepository.findAllByCharacterIdOrderByIdDesc(characterId);
}


Expand Down

0 comments on commit d8b727a

Please sign in to comment.