diff --git a/src/main/java/com/swyp8team2/comment/domain/CommentRepository.java b/src/main/java/com/swyp8team2/comment/domain/CommentRepository.java index 54e0f7e6..0dfbfbb9 100644 --- a/src/main/java/com/swyp8team2/comment/domain/CommentRepository.java +++ b/src/main/java/com/swyp8team2/comment/domain/CommentRepository.java @@ -14,8 +14,8 @@ public interface CommentRepository extends JpaRepository { SELECT c FROM Comment c WHERE c.postId = :postId - AND (:cursor is null or c.id < :cursor) - ORDER BY c.createdAt DESC + AND (:cursor is null or c.id > :cursor) + ORDER BY c.createdAt ASC """) Slice findByPostId( @Param("postId") Long postId, diff --git a/src/test/java/com/swyp8team2/comment/domain/CommentRepositoryTest.java b/src/test/java/com/swyp8team2/comment/domain/CommentRepositoryTest.java index d8a44e7d..aaa6f9ca 100644 --- a/src/test/java/com/swyp8team2/comment/domain/CommentRepositoryTest.java +++ b/src/test/java/com/swyp8team2/comment/domain/CommentRepositoryTest.java @@ -35,6 +35,6 @@ void select_CommentUser() { Slice result2 = commentRepository.findByPostId(1L, 1L, PageRequest.of(0, 10)); // then2 - assertThat(result2.getContent()).hasSize(0); + assertThat(result2.getContent()).hasSize(2); } } \ No newline at end of file