我正在尝试过滤 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>)
请指教。谢谢!
最佳答案
为了使用Specification
,您需要让您的存储库扩展JpaSpecificationExecutor
。
关于java - 如何过滤 JPA 存储库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22749222/