Results 1 to 2 of 2

Thread: Page content not populated when using pagination

  1. #1
    Join Date
    Mar 2011
    Posts
    6

    Default Page content not populated when using pagination

    Consider the following repository:
    Code:
    public interface ActivityRepository extends PagingAndSortingRepository<Activity, String> {
        public Page<Activity> findByCreatedBy(String systemUserId, Pageable pageable);
    }
    JUnit test with correct counts but empty content:
    Code:
    Page<Activity> activities = activityRepository.findByCreatedBy("123_some_id", new PageRequest(1, 1000));
    assertEquals("totalElements", activities.getTotalElements(), 2);
    assertEquals("totalPages", activities.getTotalPages(), 1);
    System.out.println("1: " + activities.getTotalElements());
    System.out.println("2: " + activities.getTotalPages());
    System.out.println("3: " + activities);
    System.out.println("4: " + activities.getContent());
    Output:
    Code:
    1: 2
    2: 1
    3: Page 1 of 1 containing UNKNOWN instances
    4: []
    So it seem like the counts are calculated correctly by the content is not added to the Page-object?
    I'm using Spring 3.1.1.RELEASE and spring-data-mongodb 1.0.1.RELEASE.

  2. #2
    Join Date
    Sep 2005
    Location
    London
    Posts
    64

    Default

    Pages start at 0 - not 1

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •