Skip to content

Commit

Permalink
Revert "Avoid duplicate sort orders through Keyset scrolling."
Browse files Browse the repository at this point in the history
This reverts commit 2e489cb.
  • Loading branch information
quaff committed Jun 12, 2023
1 parent 80916d4 commit d6a895a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

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

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

Collection<String> sortById;
Sort sortToUse;
if (entity.hasCompositeId()) {
sortById = new ArrayList<>(entity.getIdAttributeNames());
sortToUse = sort.and(Sort.by(entity.getIdAttributeNames().toArray(new String[0])));
} else {
sortById = new ArrayList<>(1);
sortById.add(entity.getRequiredIdAttribute().getName());
}

sort.forEach(it -> sortById.remove(it.getProperty()));

if (sortById.isEmpty()) {
sortToUse = sort;
} else {
sortToUse = sort.and(Sort.by(sortById.toArray(new String[0])));
sortToUse = sort.and(Sort.by(entity.getRequiredIdAttribute().getName()));
}

return delegate.getSortOrders(sortToUse);
Expand Down

This file was deleted.

0 comments on commit d6a895a

Please sign in to comment.