0

I have a problem when i implement this method in my 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);
}

Exeption: Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2018-05-23 10:33:32.606 ERROR 15048 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'maBanqueApplication': Unsatisfied dependency expressed through field 'clientRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract org.springframework.data.domain.Page org.sid.Dao.ClientRepository.chercherClient(java.lang.String,org.springframework.data.domain.Pageable)! at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:587) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]

Sana
  • 360
  • 3
  • 13

1 Answers1

2

Your query is wrong:

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

Change it to

@Query("select n from Client n where n.nom like :x")
Mạnh Quyết Nguyễn
  • 17,677
  • 1
  • 23
  • 51