Uploaded image for project: 'Spring Data JPA'
  1. Spring Data JPA
  2. DATAJPA-366

Page returns false for isFirstPage even if getTotalElements() is of 0 value

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Works as Designed
    • Affects Version/s: 1.4 M1
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None

      Description

      I noticed that the org.springframework.data.domain.Page returns false for isFirstPage and hasPreviousPage returns true even if getTotalElements() is of 0 value.

      I reckon it should look like:

      2013-07-02 11:15:33,612 DEBUG [AdminController] ==========>>> Page number: 1
      2013-07-02 11:15:33,613 DEBUG [AdminController] ==========>>> Page size: 10
      2013-07-02 11:15:33,613 DEBUG [AdminController] ==========>>> Total elements: 0
      2013-07-02 11:15:33,613 DEBUG [AdminController] ==========>>> Total pages: 0
      2013-07-02 11:15:33,613 DEBUG [AdminController] ==========>>> Is first page: true
      2013-07-02 11:15:33,613 DEBUG [AdminController] ==========>>> Is last page: true
      2013-07-02 11:15:33,613 DEBUG [AdminController] ==========>>> Has next page: false
      2013-07-02 11:15:33,613 DEBUG [AdminController] ==========>>> Has previous page: false

      and NOT like:

      2013-07-02 11:15:33,612 DEBUG [AdminController] ==========>>> Page number: 1
      2013-07-02 11:15:33,613 DEBUG [AdminController] ==========>>> Page size: 10
      2013-07-02 11:15:33,613 DEBUG [AdminController] ==========>>> Total elements: 0
      2013-07-02 11:15:33,613 DEBUG [AdminController] ==========>>> Total pages: 0
      2013-07-02 11:15:33,613 DEBUG [AdminController] ==========>>> Is first page: false
      2013-07-02 11:15:33,613 DEBUG [AdminController] ==========>>> Is last page: true
      2013-07-02 11:15:33,613 DEBUG [AdminController] ==========>>> Has next page: false
      2013-07-02 11:15:33,613 DEBUG [AdminController] ==========>>> Has previous page: true

      Indeed the number of elements is 0 because the database table was totally empty when I ran my manual test.

      This is how I found out about the issue. Simply by accident.

        Attachments

          Activity

            People

            • Assignee:
              olivergierke Oliver Gierke
              Reporter:
              stephaneeybert Stephane
              Last updater:
              Oliver Gierke
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: