如何过滤JPA存储库?

时间:2014-03-30 20:12:12

标签: java spring jpa spring-data spring-data-jpa

我正在尝试过滤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>)

请指教。谢谢!

1 个答案:

答案 0 :(得分:4)

为了使用Specification,您需要使您的存储库扩展JpaSpecificationExecutor