Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Generate smart-OR predicates for keyset scrolling#4283

Open
yeomin4242 wants to merge 3 commits into
spring-projects:mainfrom
yeomin4242:gh-4250-keyset-smart-or-predicates
Open

Generate smart-OR predicates for keyset scrolling#4283
yeomin4242 wants to merge 3 commits into
spring-projects:mainfrom
yeomin4242:gh-4250-keyset-smart-or-predicates

Conversation

@yeomin4242

Copy link
Copy Markdown

This is a follow-up to #4254. The original PR contained the smart-OR keyset predicate implementation, but it was closed after the fork branch no longer carried the diff. This PR resubmits the change from a dedicated branch and adds the missing edge-case coverage discussed in #4250.

This change optimizes keyset continuation predicates by adding an inclusive bound for the leading sort property and grouping the existing disjunction behind it.

For multi-property keysets, the generated predicate can now use a shape such as:

firstname <= ? AND (firstname < ? OR firstname = ? AND emailAddress < ?)

The fallback path keeps the existing predicate shape when the leading keyset value is null, preserving the current null-handling behavior.

Additional integration coverage walks keyset pages over datasets with duplicate leading sort values and compares the resulting sequence against regular sorted queries. The added tests cover forward scrolling, backward scrolling, nulls-last with mixed sort directions, and Querydsl predicate scrolling.

While adding the Querydsl nulls-last coverage, the null keyset equality branch was corrected to use IS NULL.

Closes #4250
Supersedes #4254

  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header.

-keyset-smart-or-predicates

Signed-off-by: YeongJae Min <[email protected]>

# Conflicts:
#	spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/QuerydslJpaPredicateExecutor.java
#	spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/UserRepositoryTests.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generate row-value tuple comparison in keyset queries when dialect supports it

3 participants