2014-03-30 59 views
3

我想篩選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>) 

請指教。謝謝 !

回答

4

爲了使用Specification s,您需要使存儲庫擴展爲JpaSpecificationExecutor

+0

謝謝!就是這樣。 – johnsam