【问题标题】:How to filter JPA repository?如何过滤 JPA 存储库?
【发布时间】:2014-03-30 20:12:12
【问题描述】:

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

请指教。谢谢!

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

    • 谢谢!就是这样。
    猜你喜欢
    • 2016-07-28
    • 2019-04-22
    • 2018-06-15
    • 2018-12-07
    • 2021-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多