Open spring-projects-issues opened 9 years ago
Oliver Drotbohm commented
Three ways to skin the cat here:
QueryMethod.getDefaulted(Pageable pageable)
and pipe the Pageable
obtained from the ParameterAccessor
through that method.ParametersParameterAccessor
to take a QueryMethod
and expose the defaults defined on QueryMethod
.QueryMethodParameterAccessor
as subtype of ParametersAccessor
to take a QueryMethod
instead of a Parameters
instance to overwrite getPageable()
and getSort()
to consider the defaults declared on the method.Thought about the conflict of both a Pageable
and Sort
declared, the latter defining a default and a value provided for the former containing a Sort.unsorted()
which would raise the question of whether to apply the sorting default rules but it seems that QueryMethod
currently does not allow both types do be declared in a single method.
Is it worth considering to allow @PageableDefault
and @SortDefault
on the type level so that it applies to all methods using Pageable
and Sort
as parameters?
Is it worth considering to allow
@PageableDefault
and@SortDefault
on the type level so that it applies to all methods usingPageable
andSort
as parameters?
We've a case for type level @SortDefault
. In Spring for GraphQL, there is auto-registration of Querydsl and Query by Example repositories to perform GraphQL queries. For pagination and sorting support, https://github.com/spring-projects/spring-graphql/issues/597, for auto-registration cases it would be useful to specify sorting preferences on such an @GraphQlRepository
.
Oliver Drotbohm opened DATACMNS-657 and commented
It would be cool if query methods on repositories would consider
@PageableDefaults
and@SortDefaults
onPageable
andSort
parameters and expose them via theQueryMethod
API.The annotation configuration should be used when
null
is provided for the corresponding parameterAffects: 1.9.2 (Evans SR2), 1.10 RC1 (Fowler)
2 votes, 3 watchers