Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: Page not being populated correctly

  1. #11
    Join Date
    Nov 2011
    Posts
    7

    Default

    Hi,

    has anyone solved this? Currently the paging functionality doesn't seem to be working at all, because it is not even possible to find out if there is a next page or not. Any suggestions on how to overcome this issue?

    Thanks,
    Radim

  2. #12
    Join Date
    Jan 2009
    Location
    Huntington Beach, CA
    Posts
    718

    Default

    In this thread Michael has said why it doesn't work and what you would need to do to get something working in your app. So no one has implemented it. Basically you need to run two queries. One for the count, and one for the actual query. And if you only do the count query once, then what happens if someone inserts new rows while you are paging, so then therefore you would need to run those two queries for each page to keep it up to date, and that is an overhead.

    Personally, I think it should be implemented with two queries that way and noted in the documentation that pagination does this. This is how Spring Data Commons says Pagination works.

    Mark

  3. #13
    Join Date
    Nov 2011
    Posts
    7

    Default

    I still think there is space for improvement. At least it would be good to have correct information whether there is next page available or not, this is a minimum which should work in my opinion.

    What I don't understand is why you would need 2 queries to do the size+1 solution which Mathieu suggested. When doing the server request, it should request size + 1 and a custom implementation of the Page interface should be returned which would only contain the requested count, and the hasNextPage method implementation of the Page interface would return whether there is an additional record or not based on existence or non existence of the additional returned result. Is this doable?

    Radim

  4. #14
    Join Date
    Jan 2009
    Location
    Huntington Beach, CA
    Posts
    718

    Default

    "When doing the server request, it should request size + 1"

    That sounds like a second count query to me.

    Just think of it in terms of the database. If I ask for 0-20 records and the query could have returned 100. How does the db know that? It doesn't so in order to find out that it would have had 100 records, is a count query. Doing a size + 1 doesn't change that fact. I don't see it.

    Mark

  5. #15
    Join Date
    Nov 2011
    Posts
    7

    Default

    I think you are misunderstanding the size + 1. I don't think a second query is needed. All I am saying is that already the first query should be constructed so that if I request 5 records, the query should retrieve 6 records and then when processing the results, it should only return the first 5 records in the Page object, but if a sixth record was returned, it means that there is an additional page.

    Radim

  6. #16
    Join Date
    Jan 2009
    Location
    Huntington Beach, CA
    Posts
    718

    Default

    But that isn't pagination. Pagination requires, to me, knowing total number of records. therefore total number of pages, next page and previous page.

    With the +1 solution you only get next page and you can figure out previous page. But not the number of pages, number of records, which some, if not many truly need. The contract of pagination in Spring Data Common is all that I just mentioned.

    So +1 wouldn't be fulfilling the contract. Now what we have doesn't fulfill the contract either, but all or nothing I guess.

    It actually would be cool if there was a property in Pagination that you could set with an enum value that would be no information, +1 information, or an extra query to get all the paging info in 2 queries.

    Mark

  7. #17
    Join Date
    Nov 2011
    Posts
    7

    Default

    Well, I would vote for having at least something rather then nothing. Plus, this something would be almost at no additional cost. I don't really understand why Spring data for Neo4j declare that pagination is supported, when in fact, although you can define methods on repository interface which return Page, you don't even know if there is a next page or not. I think it would be nice if you would be able to develop at least webpages with next and previous buttons without having to run additinal queries to get total counts...

    Radim

Posting Permissions

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