0

And another point. How to create a complex query like this?

SELECT businesscentr.email
FROM businesscentr, banners, businessbanner, click
WHERE click.id_banner = banners.id_banner AND banners.id_banner =  businessbanner.id_banner AND businessbanner.id_bc = businesscentr.id_bc

Repository extends JpaRepository<Click, Long>.

@Query("select c from Click c where c.id_bannners = :idbanners and c.fullname_client = :fullnameClient")

String sent(@Param("fullname_client") String fullnameClient, @Param("id_banner") long idbanners);

Error

 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clickController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.qoobico.remindme.server.service.ClickService com.qoobico.remindme.server.controller.ClickController.service; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clickServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.qoobico.remindme.server.repository.ClickRepository com.qoobico.remindme.server.service.ClickServiceImpl.clickRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clickRepository': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Using named parameters for method public abstract java.lang.String com.qoobico.remindme.server.repository.ClickRepository.sent(java.lang.String,long) but parameter 'fullname_client' not found in annotated query 'select c from Click c where c.id_bannners = :idbanners and c.fullname_client = :fullnameClient'!
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
    at 
New Wave
  • 113
  • 1
  • 14
  • Have you read the stack trace... Have you compared the parameter names with the actual names in the query... – M. Deinum Jan 25 '17 at 15:40

1 Answers1

1

The problem is that your param names don't match your query parameter names

You have

  @Query("select c from Click c where c.id_bannners = :idbanners and c.fullname_client = :fullnameClient")
    String sent(@Param("fullname_client") String fullnameClient, @Param("id_banner") long idbanners);

You shoud have

 @Query("select c from Click c where c.id_bannners = :id_banner and c.fullname_client = :fullname_client")
    String sent(@Param("fullname_client") String fullnameClient, @Param("id_banner") long idbanners);

That's how parameters and query match between each other

Cristian Meneses
  • 4,013
  • 17
  • 32
  • also Click is pronouncedly red. – New Wave Jan 25 '17 at 19:04
  • @new_wave the error you posted is what I described on my answer. Sometimes IDEs highlight in red the @ Query elements, because they don't recognize the entities. But solving the parameter names problem, it should work. – Cristian Meneses Jan 25 '17 at 19:41
  • my error likely in the general structure. http://stackoverflow.com/questions/41874743/error-in-query-repository/41875021?noredirect=1#comment70933224_41875021 – New Wave Jan 27 '17 at 11:19