-
Notifications
You must be signed in to change notification settings - Fork 560
Sorting by an embedded property no longer works in Ingalls RC1 [DATAREST-976] #1343
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
Alan Hay commented Seeing same behaviour after updating from Hopper to Ingalls RC1. Previously a sort could be applied on a property of a nested object (for example, an Embeddable or a sort=nestedField.property This no longer seems to work |
Mark Paluch commented That issue will be fixed with Ingalls GA, see Pull-Request 251. |
Khaled Lela commented I tried 3.0.0.M3 , But sort=nestedField.property,[asc|desc] still not working with me |
Thomas Schuh commented Sorting with nested fields does not work in current version (1.5.7) of spring boot. Is there a workaround? |
Daniele Renda commented I'm using the 3.0.2.RELEASE and I'm experiencing the issue. I'm looking for a property using the notation property_subproperty I debugged and the problem seems to be in the source code line 188 of JacksonMappingAwareSortTranslator: if (associations.isLinkableAssociation(persistentProperty)) {
return Collections.emptyList();
} This line return true and so empty the list that then later set the sort filter to null. According to the question on https://stackoverflow.com/questions/42262846/spring-data-rest-sort-by-nested-property seems there are other people with the same issue. Thanks |
Miroslav Kos commented Same issue, same line found while debugging (2.6.8.RELEASE) |
Radu Vanciu commented For the 2.6.9 RELEASE, I tested the issue and I can confirm that it works as expected (see Pull-Request 251). The nested sort is however restricted to properties annotated with I found this implementation a bit too restrictive, and I am looking for a workaround as well, since we want both linkable association and the nested sorting. For example, we need the nested sorting to work for The workaround I found so far is to create an extra read only property for sorting purposes only. Building on the example from https://stackoverflow.com/questions/42262846/spring-data-rest-sort-by-nested-property
The drawback for the proposed workaround is that we now have to explicitly duplicate all the properties for which we want to support nested sorting. Are there other workarounds? Would it be possible to configure the sort translator to relax the restrictions to properties with fetch=FetchType.EAGER associations? |
Daniele Renda commented Any will to fix this problem? The issue is still closed. Thanks |
Mark Paluch commented With Ingalls we changed the sorting behavior. It's possible to sort on nested object's properties, it's not possible to sort by association properties as they're seen from a REST perspective. You're not able to sort by properties of a referenced aggregate root if that one is exported |
Daniele Renda commented Thanks for your explanation. Is there another way to accomplish this? Let's say I've a bean like this: @Entity
public class Customer extends AbstractEntity {
private String name;
@ManyToOne(fetch = FetchType.LAZY, optional = true)
private Address address;
} Typically in the GUI when I've a customer's table I want to sort by customer's properties, but I could also want to sort by address.name. Because address is exposed how am I supposed to accomplish to this if the sorting behaviour is changed? Thanks |
Jens Fischer commented We were facing the same problem (using Spring Boot 1.5.9 with Spring Data REST 2.6.9). The nested property that we tried to use for sorting was covered with a Jackson Mixin containing |
Antonio Petrelli commented I noticed that the piece that excludes linkable associations (i.e. associations to entity exposes as resources via a repository) is due to the method:
IMHO this has no sense, why do you need to exclude them? |
Antonio Petrelli commented I just noticed that Daniele Renda said the exact same thing, sorry for the noise. However it still does not make sense to me |
anasofiapaixao commented I stumbled upon the exact same issue and am extremely surprised this could be considered the expected behavior. At my job we went through the work of bumping our spring-boot version, I now regret it immensely and if I knew a version upgrade would result in the loss of basic, essential functionality with no viable alternative I would have never done it. There's dozens upon dozens of questions on stackoverflow from people desperate to do just this, with no answer or alternative that does not involve a multiplication of query methods and god knows how many if-elses in the frontend. This was an essential feature |
Daniele Renda commented I agree with anasofiapaixao, this is a very important feature. The issue is still in status "closed". Someone could ask for a revaluation and reopen it? |
Daniele Renda commented Any news? Thanks |
Predrag commented Looks similar to https://jira.spring.io/browse/DATAREST-1024
At least it's still open and considered as a Major issue.
|
Daniele Renda commented Thanks! |
Stefan Gybas opened DATAREST-976 and commented
I have a JPA entity with embedded class and a corresponding
PagingAndSortingRepository
that is accessed using Spring Data REST. I like to sort by a property in the embedded class.Please see https://github.com/sgybas/spring-data-sorting-bug for a repro. The test passes with Spring Boot 1.4.3 (Spring Data Hopper-SR) but fails with Spring Boot 1.5.0.RC1 (Spring Data Ingalls RC1). The test also passes if I sort by the entity's id so the problem only occurs with embedded classes
Affects: 2.6 RC1 (Ingalls)
Reference URL: https://github.com/sgybas/spring-data-sorting-bug
Referenced from: pull request #251, and commits 99f4953, 3c6f311, 5212d13, ffe96e4, 69c3937, 97bae7a, 0f9ee7d, c1fb7bf
Backported to: 2.6 GA (Ingalls)
1 votes, 14 watchers
The text was updated successfully, but these errors were encountered: