-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Custom query with sort parameter [DATAJDBC-589] #811
Comments
Mark Paluch commented Using Spring Data JPA has partial support for dynamic sorting and we've learned from there that parsing SQL comes with quite some complexity and it's easy to break the parser using e.g. joins or subselects. Therefore we don't plan to support |
Jens Schauder commented As Mark explained above, currently we would need to parse the SQL statement which we don't want to get into. This will take a while though. |
@spring-projects-issues kremerkp is not issuing adding dynamic Sort and Pageable to custom query like JPA. It's that the :order parameter won't work in this query. @Query("select * from person where firstname = :name" + " order by :order") stackoverflow Here is a good explanation about the root cause. It's not about Spring Data Jdbc, but still, user can get confused about the result. |
Wow, was just about to submit a new issue and found this one. @spring-projects-issues, just make it possible to define |
Dynamically identifying But using a special kind of placeholder for this, plus maybe a configurable prefix could be an interesting idea. Something like:
@mp911de What do you think? |
Interesting, in my case after enabling TRACE for the mariadb client, I clearly could see that the SQL ( Anyway it is clear that it is a hack to be used like this and I would appreciate to see your suggestion working |
That would be done by the JDBC client. If you enable logging for |
Yes, u r right, just double checked, indeed the jdbc keeps it all |
@schauder, just a question, because we are in a kind of Patt situation. We would like to proceed with native spring data jdbc as we progressed pretty much with it purely, but need above placeholder feature now. Thanks |
This won't be included in 2.4.x if at all it would go into 3.2. And honestly that most certainly won't happen since we have already a lot of stuff planned for 3.2 |
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:
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
The text was updated successfully, but these errors were encountered: