Skip to content

Commit d6a895a

Browse files
committed
Revert "Avoid duplicate sort orders through Keyset scrolling."
This reverts commit 2e489cb.
1 parent 80916d4 commit d6a895a

File tree

2 files changed

+2
-91
lines changed

2 files changed

+2
-91
lines changed

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/KeysetScrollSpecification.java

+2-14
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
import jakarta.persistence.criteria.Predicate;
2323
import jakarta.persistence.criteria.Root;
2424

25-
import java.util.ArrayList;
26-
import java.util.Collection;
2725
import java.util.List;
2826

2927
import org.springframework.data.domain.KeysetScrollPosition;
@@ -63,21 +61,11 @@ public static Sort createSort(KeysetScrollPosition position, Sort sort, JpaEntit
6361

6462
KeysetScrollDelegate delegate = KeysetScrollDelegate.of(position.getDirection());
6563

66-
Collection<String> sortById;
6764
Sort sortToUse;
6865
if (entity.hasCompositeId()) {
69-
sortById = new ArrayList<>(entity.getIdAttributeNames());
66+
sortToUse = sort.and(Sort.by(entity.getIdAttributeNames().toArray(new String[0])));
7067
} else {
71-
sortById = new ArrayList<>(1);
72-
sortById.add(entity.getRequiredIdAttribute().getName());
73-
}
74-
75-
sort.forEach(it -> sortById.remove(it.getProperty()));
76-
77-
if (sortById.isEmpty()) {
78-
sortToUse = sort;
79-
} else {
80-
sortToUse = sort.and(Sort.by(sortById.toArray(new String[0])));
68+
sortToUse = sort.and(Sort.by(entity.getRequiredIdAttribute().getName()));
8169
}
8270

8371
return delegate.getSortOrders(sortToUse);

spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/KeysetScrollSpecificationUnitTests.java

-77
This file was deleted.

0 commit comments

Comments
 (0)