【发布时间】:2016-02-12 07:37:29
【问题描述】:
我有一个简单的 REST 服务,它使用 Spring boot CrudRepository 访问数据。
这个存储库已经实现了这样的分页和排序功能:
public interface FlightRepository extends CrudRepository<Flight, Long> {
List<Flight> findAll(Pageable pageable);
}
调用它:
Sort sort = new Sort(direction, ordering);
PageRequest page = new PageRequest(xoffset, xbase, sort);
return flightRepo.findAll(page);
我还想向此存储库添加过滤(例如,仅返回带有id > 13 AND id < 27 的实体)。 CrudRepository 似乎不支持此功能。有什么方法可以实现这一点还是我需要使用不同的方法?
感谢您的任何提示!
【问题讨论】:
标签: java rest spring-boot spring-data spring-data-jpa