Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for pagination, without the need of a count query [DATACMNS-397] #866

Closed
spring-projects-issues opened this issue Nov 12, 2013 · 2 comments

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Nov 12, 2013

Kostas Kokkoros opened DATACMNS-397 and commented

Currently, if you declare a repository method that returns Page<T>, a count query will be executed. But this is not always required or desired. If for example you have only "Next" and "Previous" buttons in a list page, then you are only interested in whether there is a previous/next page or not, and not in the total number of pages in the database.

One possible implementation would be to create a new interface that excludes the getTotalPages() and getTotalElements() of the Page interface. This new interface could then be added to return types of methods. The check of whether there is a next page or not could be done by requesting one more element than specified in the Pageable parameter. If there is then we have a next page (and of course this element will be removed from the return results)


Issue Links:

Referenced from: commits spring-projects/spring-data-jpa@62b4b37, spring-projects/spring-data-jpa@c8ca0f8

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Feb 25, 2014

Oliver Drotbohm commented

To be able to expose whether the slice (the term we intenally use to make sure we can distinguish from pages) has a previous one we'd also have to expand the amount of items being read on the start index side as well. We were wondering whether that would potentially cause too much overhead for small page sizes.

Do you think it makes sense to start with an hasNext() method only and potentially add the hasPrevious() if more people ask for that?

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Mar 3, 2014

Kostas Kokkoros commented

I thought that if you requested a page different that the first and there where results, then there should be a previous page. So I don't understand why you need to expand the items to start index minus one. But you know better.

To answer your question thought, I cannot think of a use case that warrants the use of the hasNext() method without an accompanying hasPrevious()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants