In order to use Specification
s you need to make your repository extend JpaSpecificationExecutor
.
How to filter JPA repository?
-
24-06-2023 - |
Question
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 !
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow