-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
KeysetScrollSpecification null properties support #3605
Comments
Not quite sure what you're asking for. The general issue is that various databases may have support for null precedence in ordering while others don't support null precedence. Also, JPA doesn't support the specification of null precedence. This is scheduled for the next JPA spec release. It would help if you come up with a bit more of an example, how you envision things should work so that we can find out whether this ticket can become actionable. |
I am talking about Not having
WHERE (created_at IS NOT NULL AND created_at > ?) OR (created_at IS NULL AND id > ?) My proposal is to allow null keys for creating To preserve backwards compatibility for
It should produce such query: SELECT * |
If we support This could actually be achieved with adding an additional virtual field to the where clause generation which is Still I'm afraid this might be bad for performance, so I think we should find a way to only apply this to fields which are nullable. IF we get all this working, I don't think we need a "fallback" we only need the combinations of all fields in the key set to be unique. |
Of course. It is another issue which is related to ORDER BY clause which comes after WHERE conditions, because WHERE conditions alone would not solve issue completely. I believe there is another task for ORDER BY in github issues.
Yes, agree. The implementation code should be in control to make field nullable or not, maybe only by default all fields should not be nullabe. But at least one field should be not null to make pagination work. |
The where clause is actually all about ordering. After all, we are trying to select the next |
Map<String, Object> keys = new LinkedHashMap<>();
keys.put("createdAt", entity.getCreatedAt());
keys.put("id", entity.getId()); @ivan-zaitsev FYI, |
It is documented here that keyset-filtering requires all the keyset properties to be non-nullable.
But will it actually affect indexing/ordering by adding
cb.isNull()
condition for some of the properties to https://github.com/spring-projects/spring-data-jpa/blob/main/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/KeysetScrollSpecification.java#L120 ?Generated query examples:
The text was updated successfully, but these errors were encountered: