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

Derived query applies OffsetScrollPosition only if the query is limited #3015

Closed
sergey-morenets opened this issue Jun 12, 2023 · 0 comments
Closed
Assignees
Labels
type: bug A general bug

Comments

@sergey-morenets
Copy link

Hi

We have the following repository:

public interface ProductRepository extends 
		JpaRepository<Product, Integer>, JpaSpecificationExecutor<Product> {
	
	Window<Product> findBy(ScrollPosition position);

And there are 20 product records in the database. So when we execute this piece of code then nothing is returned as we request page #4 with page size of 5 elements:

		PageRequest pageRequest = PageRequest.of(4, 5);
		Page<Product> productPage = productRepository.findAll(pageRequest);
		int size = productPage.getContent().size();  // 0

And when we convert PageRequest into OffsetScrollPosition we expect that it would return 0 records as well (offset is correct and equal to 20):

		OffsetScrollPosition position = pageRequest.toScrollPosition();
		long offset = position.getOffset();  // 20
		Window<Product> window = productRepository.findBy(position);
		
		for(Product product: window) {
			System.out.println(product);
		}
		
		size = window.getContent().size();

But this code returns all the existing records (20).

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 12, 2023
@mp911de mp911de self-assigned this Jun 19, 2023
@mp911de mp911de added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 26, 2023
@mp911de mp911de changed the title Inconsistent behavior of Scrolling API Derived query applies OffsetScrollPosition only if the query is limited Jun 26, 2023
@mp911de mp911de added this to the 3.1.2 (2023.0.2) milestone Jun 26, 2023
mp911de added a commit that referenced this issue Jun 26, 2023
We now apply the scroll position correctly regardless of whether the query is limited.
Previously, we applied the position only if the query was limited.

Closes #3015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants