java - 如何过滤 JPA 存储库?

标签 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>)

请指教。谢谢!

最佳答案

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

关于java - 如何过滤 JPA 存储库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22749222/

相关文章:

JAVA 在查找后使用 RandomAccessFile 非常慢。是什么原因?

java - 使用随机访问文件删除记录

java - Flyway 没有选择我的 sql 文件进行迁移

Java JPA 从 oracle 数据库检索 blob 作为其原始文件类型

java - 复选框和相应行的值从 jsp 到 java Controller 文件

hibernate - Glassfish 到野蝇迁移(从 Eclipse 链接到 Hibernate): LazyInitializationException

java - 如何将自定义转换器与@DataMongoTest 一起使用?

java - 在 RabbitMQ 监听器中隐藏运行时异常

java - 使用同一个表的多个 JPA 实体

java - 基本 JPA 问题 : "Could not determine type for: java.util.Set"