Skip to content

Extension special types (Pageable and Sort) to subtypes (e.g. PageRequest, etc.) #2627

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

Closed
wants to merge 2 commits into from

Conversation

gregturn
Copy link
Contributor

If someone defines a custom finder using a subtype, like findByLastname(String lastname, PageRequest page), Spring Data Commons will fail to properly handle it, since it has a strict members-only policy for special types.

This list should be extended to subclasses so a custom finder using any of these subtypes will also work.

Closes #2626.

@gregturn gregturn requested a review from mp911de May 11, 2022 21:46
Spring Data Commons has a hard-coded list of special types than can be included in query methods including Pageable and Sort.

A custom finder with PageRequest, even though it extends Pageable, will fail when it would work fine with a narrowed input. This extends the list using an isAssignableFrom check.

Related: spring-projects/spring-data-jpa#2013

See #2626.
* @param parameterType
* @return boolean
*/
private static boolean isSpecialParameterType(Class<?> parameterType) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should refrain from using Java 8 Streams due to performance reasons.

@odrotbohm
Copy link
Member

That's polished and merged.

@odrotbohm odrotbohm closed this May 12, 2022
@gregturn gregturn deleted the issue/gh-2626 branch May 12, 2022 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend support for special parameters to instances.
3 participants