jakartaee/data

[clarification]: TCK makes mandatory hasNext method at Pagination.

otaviojava opened this issue · 4 comments

Specification

https://github.com/jakartaee/data/blob/main/api/src/main/java/jakarta/data/page/Page.java#L86-L91

I need clarification on ...

Requiring a hasNext method for pagination is problematic for NoSQL databases like DynamoDB, Redis, Cassandra, Couchbase, and HBase, which lack native support for this feature. These databases use alternative pagination strategies such as ExclusiveStartKey, paging_state, or custom logic.

Thus, Assertion 133 needs to be updated.

Methods:

  • testCursoredPageOfNothing()
  • testOrderByHasPrecedenceOverPageRequestSorts()
  • testThirdAndFourthPagesOf10()

Additional information

No response

After reviewing the documentation for hasNext,

     * Returns {@code true} if it is known that there are more results or that it is
     * necessary to request a next page to determine whether there are more results, ...
     * @return {@code false} if this is the last page of results.

and all 3 of the TCK tests that you cited, all of those tests are well written according to the requirements, and the requirements are correct to allow hasNext to be implemented on the Jakarta Data provider side without native support by databases. The Jakarta Data provider can easily determine if it did or did not receive a full page of results. If not a full page, you can return false. If it is a full page, the JavaDoc permits you to return true without knowing if there will or will not be more results. The TCK tests allow that behavior. I don't see any issue here.

That makes sense. Thank you.

@njr-11

I put it as true, but I got an issue now on this one:
testBeyondFinalPage()

This happens because:

 assertEquals(43L, page.totalElements());

I put it as true, but I got an issue now on this one: testBeyondFinalPage()

This happens because:

 assertEquals(43L, page.totalElements());

I don't see why you should reopen this issue for a problem you are having with testBeyondFinalPage. That test case doesn't even use page.hasNext. If you are experiencing a new problem, you should open a new git issue for it and report and include the error message, exception stack, and any other detail that would be helpful in understanding it.