Skip to content
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

Sort collection resource by associated property [DATAREST-1280] #1641

Open
spring-projects-issues opened this issue Aug 29, 2018 · 0 comments · May be fixed by #2328
Open

Sort collection resource by associated property [DATAREST-1280] #1641

spring-projects-issues opened this issue Aug 29, 2018 · 0 comments · May be fixed by #2328
Assignees
Labels
type: bug A general bug

Comments

@spring-projects-issues
Copy link

cptwunderlich opened DATAREST-1280 and commented

Collection resources can't be sorted by associated properties.

This is a huge and quite franky not very understandable limitation.

I have prepared an example - link can be found in "Reference URL".

The example uses Articles having a Unit. Querying via JPQL like in the Unit Test works like a charm. Just passing "unit.code" works and since that is the primary key, no join is needed. Adding "unit.fullName" to the query automatically uses a join, without changing the query.

I've also added QueryDsl to the Example, to show how strange it seems, that you can filter by a property, but you can't sort by it.

Where this is really stands out is with Projections/Excerpts. I want to list my Articles and I'd like to sort by Unit. Now I'm including the Unit's abbreviation or code in the Projection and knowing the property name, I can even filter it - but I just can't sort by it.

 

Digging through the framework, I found JacksonMappingAwareSortTranslator.mapPropertyPath(), which returns if it finds a linkable association, instead of continuing creating the 'sort' property. Why? What's the rationale?


Affects: 3.0.9 (Kay SR9)

Reference URL: https://github.com/cptwunderlich/SpringDataRestMWEs/tree/master/AssociationSort

2 votes, 3 watchers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
2 participants