-
Notifications
You must be signed in to change notification settings - Fork 560
Cannot server side sort by child entity field using Spring Data Rest [DATAREST-1024] #1386
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
Comments
Predrag commented Hello,
This issue is still present in SDR 3.1.4 as well as SDR 3.2.0.M1 .. From the DATAREST-976 I'm concluding that this still isn't supposed to be fixed even in latest releases. I wonder however why using associations is working perfectly for filtering, but cannot be fixed/implemented for sorting?
|
HZ commented any update on this one? upgrading from spring-data-rest-webmvc:2.3.0.RELEASE to the latest causes this issue |
No update in 11 months? This seems like a pretty big regression, workarounds we implemented are spectacularly Janky and I don’t want to have to maintain them. Please fix this |
I also just stumbled over this error and am also wondering why filtering is possible between two tables but sorting is not. I don't even get any exceptions during the sort, it just passes back the results but without applying the sorting - like described in DATAREST-976. |
Try use "." in your request. Example http://localhost:8080/api/user/all-experts?sort=doctor.mainInstitution.city.name. You need only Paging and sorting interface implemented. |
Thanks. I had another look on the issue. We have a path like this:
Where @Valid
@ManyToOne
private MyJavaType entityB When executing the request, the execution gets into JacksonMappingAwareSortTranslator.translateSort where the If I would force the method Especially because it would work, I don't really understand why this explicit check for the association is done. Would it be possible to release a fix just checking the cases that really need to be checked? |
Hi. So using his example, my entity now looks like this
|
Lash Sanghera opened DATAREST-1024 and commented
I am implementing server side sorting with Spring Data REST and Spring Data JPA included in Spring Boot 1.3.1.RELEASE version. The JPA entity I would like to sort the results by has many to one entiry budgetPool.name
I display budgetPool.name on UI with the option to sort the results by budget pool name. The following URL to sort budget pool by id work:
But the following url to sort by budget pool name throws java.sql.SQLSyntaxErrorException: invalid ORDER BY expression:
My Repository has a custom query to return paged transactions based on the search parameters passed.
If I remove DISTINCT the sorting by bugetPool.name work fine but I get duplicate results in my query.
I asked this question on stackoverflow few weeks back but no helpful reply.
Thank you for your help in advance.
Reference URL: http://stackoverflow.com/questions/42112047/cannot-server-side-sort-by-child-entity-field-using-spring-data-rest
6 votes, 7 watchers
The text was updated successfully, but these errors were encountered: