我有一个使用Spring Boot 1.5.1和Spring Data Rest的数据库服务.我将我的实体存储在MySQL数据库中,并使用Spring的PagingAndSortingRepository通过REST访问它们.我发现this声明支持按嵌套参数排序,但我找不到按嵌套字段排序的方法.
我有这些课程:
@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,etc.
}
例如,使用该方法时:
Page
调用URI http://localhost:8080/people/search/findByAddress_Id?id=1&sort=name_lastName,desc时,Spring完全忽略sort参数.
参数sort = name.lastName和sort = nameLastName也不起作用.
我是否构成了Rest请求错误,或者缺少某些配置?
谢谢!
最佳答案