簡體   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