Search code examples
javamongodbspring-mongo

Paging not working with mongo repository


I have the following code to store a repository of comments, and find them by the ID of the post that they have been attributed to:

@RepositoryRestResource(path = "/comments")
public interface CommentsRestRepository extends MongoRepository<Comment, String> {
    Page<Comment> findByPostID(@Param("postID") String postID, Pageable pageable);
}

When using the URL http://localhost:8080/comments/search/findByPostID?postID=55ff128577c8dc3d6b311da7 it works. However, if I add a &page=1&size=5 or any other combination of page/size/sort, it completely ignores these parameters. Why is this?


Solution

  • I was using curl and you have to use quotation marks around the URL for the whole expression to be evaluated!