I have a database service using Spring Boot 1.5.1 and Spring Data Rest. I save my objects in a MySQL database and access their REST using Spring PagingAndSortingRepository. I found this , which says that sorting by nested parameters is supported, but I cannot find a way to sort by nested fields.
I have the following classes:
@Entity(name = "Person") @Table(name = "PERSON") public class Person { @ManyToOne protected Address address; @ManyToOne(targetEntity = Name.class, cascade = { CascadeType.ALL }) @JoinColumn(name = "NAME_PERSON_ID") protected Name name; @Id protected Long id; // Setter, getters, etc. } @Entity(name = "Name") @Table(name = "NAME") public class Name{ protected String firstName; protected String lastName; @Id protected Long id; // Setter, getters, etc. }
For example, when using the method:
Page<Person> findByAddress_Id(@Param("id") String id, Pageable pageable);
And by calling the URI http: // localhost: 8080 / people / search / findByAddress_Id? Id = 1 & sort = name_lastName, desc , the sort parameter is completely ignored by Spring.
The parameters sort = name.lastName and sort = nameLastName did not work either.
Am I incorrectly generating a vacation request or canβt see any configuration?
Thanks!
source share