You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Returns whether the current scroll position is the initial one.
The javadoc of Window.positionAt() states:
Returns the {@link ScrollPosition} at {@code index}.
It doesn't state position at zero must be initial one, I don't think it's a bug.
Could you share your actual use case to check ScrollPosition.isInitial() ?
What @quaff said. Conceptually, the initial position starts before index zero as it describes the position before the first element.
Regardless of keyset or offset mechanisms, if you request the next Window as of previous.positionAt(0) then the next window starts after the first element of the initial window of data.
Hello, I have a problem trying to check if my query is in the first position:
When calling it, it returns 2 records:
but
window.positionAt(0).isInitial()
always returnsfalse
The reason apparently lies in the
JpaMetamodelEntityInformation.getKeyset
method which always returns at least one key set:spring-data-jpa/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/JpaMetamodelEntityInformation.java
Line 233 in 1b50d23
getKeyset
is used inScrollDelegate.createWindow
:spring-data-jpa/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/ScrollDelegate.java
Line 89 in 1b50d23
and by calling
window.positionAt(0).isInitial()
, theKeysetScrollPosition.isInitial
method checks the loaded keys where it always finds at least one and returnsfalse
:https://github.com/spring-projects/spring-data-commons/blob/30dcacc8c1ef11d70580f7f79927122590a71ac7/src/main/java/org/springframework/data/domain/KeysetScrollPosition.java#L140
The text was updated successfully, but these errors were encountered: