我正在尝试过滤JPA存储库
@RequestMapping("/search")
public String search(@ModelAttribute Person search, Model model) {
PersonSpecifications spec = new PersonSpecifications();
model.addAttribute("people", this.hotelRepository.findAll(spec.lastNameIsLike("Foo")));
return "people/list";
}
并收到以下错误
The method findAll(Iterable<Long>) in the type CrudRepository<Person,Long> is not applicable for the arguments (Specification<Person>)
请指教。谢谢!
答案 0 :(得分:4)
为了使用Specification
,您需要使您的存储库扩展JpaSpecificationExecutor
。