繁体   English   中英

带有查询方法的Spring JPA仓库实例

[英]Spring JPArepository Exeption with query method

我在ClientRepository中实现此方法时遇到问题:

public interface ClientRepository extends JpaRepository<Client,Long> {
    @Query("select n from Client where n.nom like :x")
    public Page<Client> chercher(@Param("x") String mc , Pageable pageable);
}

示例:启动ApplicationContext时出错。 要显示条件报告,请在启用“调试”的情况下重新运行您的应用程序。 2018-05-23 10:33:32.606错误15048 --- [restartedMain] osboot.SpringApplication:应用程序运行失败

org.springframework.beans.factory.UnsatisfiedDependencyException:创建名称为“ maBanqueApplication”的bean时出错:通过字段“ clientRepository”表示的不满意的依赖关系; 嵌套的异常是org.springframework.beans.factory.BeanCreationException:创建名称为'clientRepository'的bean时出错:调用init方法失败; 嵌套异常为java.lang.IllegalArgumentException:方法公共抽象org.springframework.data.domain.Page org.sid.Dao.ClientRepository.chercherClient(java.lang.String,org.springframework.data.domain。的查询的验证失败。分页)! 在org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor $ AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:587)〜[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]在org.springframework.beans处。 factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91)〜[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]

您的查询是错误的:

@Query("select n from Client where n.nom like :x") // You select `n` from no where

更改为

@Query("select n from Client n where n.nom like :x")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM