I am trying to filter JPA repository

@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";
    }

And got the following error

The method findAll(Iterable<Long>) in the type CrudRepository<Person,Long> is not applicable for the arguments (Specification<Person>)

Please advise. Thanks !

有帮助吗?

解决方案

In order to use Specifications you need to make your repository extend JpaSpecificationExecutor.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top