Skip to content
New issue

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

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

Already on GitHub? # to your account

Page has an incorrect total since 3.4.3 #3802

Closed
Roberto-Mol opened this issue Mar 5, 2025 · 5 comments
Closed

Page has an incorrect total since 3.4.3 #3802

Roberto-Mol opened this issue Mar 5, 2025 · 5 comments
Assignees
Labels
status: duplicate A duplicate of another issue

Comments

@Roberto-Mol
Copy link

Roberto-Mol commented Mar 5, 2025

We are using spring-data-jpa to perform a query using a JpaRepository that returns a Page object. I am seeing different behaviour with spring-data-jpa 3.4.2 compared to spring-data-jpa 3.4.3.

Use-case

  • There are 44 records in my database table that should be found when running the query.
  • I am asking paged results, with a page size of 20 and page number 1 (the second).

3.4.2

  • The resulting page has a total of 44, independent of the page number I requested.

3.4.3

  • The resulting page has a varying total, depending on the page number I requested:
    • page number 0 --> total = 20
    • page number 1 --> total = 40
    • page number 2 --> total = 44

I could not find anything in the release notes, and in my (not-so-informed) opinion the behaviour in 3.4.2 makes more sense. This feels like a bug to me.

I would appreciate any response, whether it's an explanation why this new result is better or whether it's a confirmation that I've indeed found a bug.

If this issue is not according to your standards, please let me know.

Edit
SimpleJpaRepository.readPage() returns a total of 44 independent of the specified page number (i.e. is correct).
JpaQueryExecution.doExecute() returns a total of 20/40/44 depending on the page number (i.e. is incorrect).

One of our endpoints does the search via a .findAll() call on a JpaRepository, which will trigger the SimpleJpaRepository.readPage() call, while another endpoint of us does the search via a custom method annotated with @query on a JpaRepository, which will trigger the JpaQueryExecution.doExecute().

Hopefully this helps. It helped me see that we have a possible work-around, though I still think there is a bug that should be resolved.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 5, 2025
@mp911de
Copy link
Member

mp911de commented Mar 6, 2025

If you would like us to spend some time helping you to diagnose the problem, please spend some time describing it and, ideally, providing a minimal yet complete sample that reproduces the problem.
You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

@mp911de mp911de added the status: waiting-for-feedback We need additional information before we can continue label Mar 7, 2025
@spring-projects-issues
Copy link

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Mar 14, 2025
@Roberto-Mol
Copy link
Author

Thank you for your response. I have attached a minimal yet complete sample.
Simply run mvn clean install or execute the tests in SpringBootErrorTest.java.

You will see that the repository query tests fails, because the total elements are 3 (equal to page size) instead of 10. You will see that the specification test succeeds. This is with spring-boot-starter-parent version 3.4.3. using spring-data-jpa version 3.4.3.

If you change the version of spring-boot-starter-parent to 3.4.2 (using spring-data-jpa version 3.4.2), then you will see that both tests succeed.

I hereby conclude that there is a bug in spring-data-jpa version 3.4.3.

If you need any more information, please let me know.

Spring-Data-JPA-Page-Bug.zip

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue labels Mar 17, 2025
@mp911de mp911de self-assigned this Mar 17, 2025
@mp911de
Copy link
Member

mp911de commented Mar 19, 2025

This is a variant of #3784. Upgrading to Spring Data JPA 3.4.4 (in Spring Boot, setting <spring-data-bom.version>2024.1.4</spring-data-bom.version>) fixes the broken test for me.

@mp911de mp911de closed this as completed Mar 19, 2025
@mp911de mp911de added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Mar 19, 2025
@Roberto-Mol
Copy link
Author

Thanks for your time and your suggestion. It worked like you said :).

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants