spring-projects / spring-projects/spring-data-relational
Custom query with sort parameter [DATAJDBC-589]
@schauder is already working on this.
Since Dec 31, 2020.
- Dominant language
- Java
- Stars
- 827
- Forks
- 394
- PR merge metrics
- No merged PRs in 30d
Description
kremerkp opened DATAJDBC-589 and commented
I try to add an dynamicly "order by" clause by passing a parameter inside a custom query. Limit and offset are working fine as parameters, only the order by is not recognized
Example:
// code public interface CustomerRepository extends PagingAndSortingRepository<Customer, Long>
@Query("select * from person where firstname = :name" + " order by :order")
List<Customer> findByFirstNameCustomQuery(@Param("name") String name,
Pageable page, @Param("order") String order);
The query that I normaly use is more complex, so that I wont be able to use query creation from method names.
Is there a workaround or will it be "fixed/added" in a future release?
I also added a small GitHub Repo do demonstrate the problem;
https://github.com/kremerkp/spring-data-jdbc-pageable-h2
Reference URL: https://stackoverflow.com/questions/63285038/spring-data-customized-query-with-order-parmeter-nor-working
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.