Announcement Announcement Module
Collapse
No announcement yet.
Page content not populated when using pagination Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Pages start at 0 - not 1

    Comment

    Working...
    X