我有实体Market
和Event
.Market
实体有一列:
@ManyToOne(fetch = FetchType.EAGER) private Event event;
接下来我有一个存储库:
public interface MarketRepository extends PagingAndSortingRepository{ }
和投影:
@Projection(name="expanded", types={Market.class}) public interface ExpandedMarket { public String getName(); public Event getEvent(); }
使用REST查询/api/markets?projection=expanded&sort=name,asc
我成功获得了按市场名称排序的嵌套事件属性的市场列表:
{ "_embedded" : { "markets" : [ { "name" : "Match Odds", "event" : { "id" : 1, "name" : "Watford vs Crystal Palace" }, ... }, { "name" : "Match Odds", "event" : { "id" : 2, "name" : "Arsenal vs West Brom", }, ... }, ... } }
但我需要的是获取按事件名称排序的市场列表,我尝试了查询,/api/markets?projection=expanded&sort=event.name,asc
但它没有用.我该怎么做才能让它发挥作用?