Skip to content
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

Sorting of Pageable.unpaged(sort) is ignored by JPA Repository #3476

Closed
azizairo opened this issue May 15, 2024 · 2 comments
Closed

Sorting of Pageable.unpaged(sort) is ignored by JPA Repository #3476

azizairo opened this issue May 15, 2024 · 2 comments
Assignees
Labels
type: enhancement A general enhancement

Comments

@azizairo
Copy link

azizairo commented May 15, 2024

I have case when i need unpaged result with sort order. So to implement this i just used Pageable.unpaged method that allows to pass Sort parameter and I am expacting that jpa repository will return unpaged but sorted result. But it is not working cause jpa repostiory ignores sorting for unpaged request:

@Override
	public Page<T> findAll(Pageable pageable) {

		if (pageable.isUnpaged()) {
			return new PageImpl<>(findAll());
		}

		return findAll((Specification<T>) null, pageable);
	}

Is it possible to change behavior to this:

@Override
	public Page<T> findAll(Pageable pageable) {

		if (pageable.isUnpaged()) {
                        if(pageable.getSort().isSorted()) {
                              return new PageImpl<>(findAll(pageable.getSort()));
                        }
			return new PageImpl<>(findAll());
		}

		return findAll((Specification<T>) null, pageable);
	}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 15, 2024
@quaff
Copy link
Contributor

quaff commented May 16, 2024

I think it's reasonable, It's better to submit a PR instead.

@mp911de mp911de added type: enhancement A general enhancement status: ideal-for-contribution An issue that a contributor can help us with and removed status: waiting-for-triage An issue we've not yet triaged labels May 16, 2024
@azizairo
Copy link
Author

Ok, I will try to work on PR

yoa1226 added a commit to yoa1226/spring-data-jpa that referenced this issue Jun 18, 2024

Verified

This commit was signed with the committer’s verified signature.
IvanGoncharov Ivan Goncharov
Resolves: spring-projects#3476
Original pull request: spring-projects#3514
yoa1226 added a commit to yoa1226/spring-data-jpa that referenced this issue Jun 18, 2024

Partially verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
Resolves: spring-projects#3476
Original pull request: spring-projects#3514
@christophstrobl christophstrobl self-assigned this Jul 1, 2024
@mp911de mp911de added this to the 3.4 M1 (2024.1.0) milestone Nov 14, 2024
@mp911de mp911de linked a pull request Nov 14, 2024 that will close this issue
4 tasks
@mp911de mp911de removed the status: ideal-for-contribution An issue that a contributor can help us with label Feb 17, 2025
mp911de pushed a commit that referenced this issue Feb 17, 2025
This commit makes sure to pass on a given Sort from an unpaged Pageable to the actual query.

Closes: #3476
Original Pull Request: #3517
@mp911de mp911de marked this as a duplicate of #3778 Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants