Spring Error with JPQL: Unsatisfieddependencyexception

Asked

Viewed 266 times

0

I’m doing a REST API in Spring Boot and I’m having a hard time bringing the results of a Repository query.

I have this MER, which is a small part of my bank:

inserir a descrição da imagem aqui

I built these two entities in Java, which resulted in the following classes (omitted getters, setters and Imports from all following classes so the images don’t get too big):

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

As the same street (that is, an avenue, for example) can have several Zip Codes (see Avenida Sapopemba, Avenida Paulista etc), then the query should return me to the Street with a list of Street Codes (if the same Street has more than one zip code). I can search for any of the three parameters: either by nameLogradouro (Street class) or by numeroCepLogradouro and numeroCepComplementLogradouro (Street class).

My Repository is like this:

inserir a descrição da imagem aqui

My kind of service is like this:

inserir a descrição da imagem aqui

And my controller is like this:

inserir a descrição da imagem aqui

But when I run the project, it makes the following mistake:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'logradouroApiController': Unsatisfied dependency expressed through field 'logradouroService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'logradouroService': Unsatisfied dependency expressed through field 'logradouroDao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'logradouroDao': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.projeto.referencia.dao.LogradouroDao.findLogradouroByParameters(java.lang.String,java.lang.Integer,java.lang.Integer)!

The project is configured 100% straight:

inserir a descrição da imagem aqui

I think I’m doing some nonsense when returning the list of Logradourocep (who is the daughter of the object Logradouro) of the query. Could someone please help me?

  • Good Morning, your makers are public or private?

  • Hello! I suggest exchanging the images for text, because then people with a problem similar to yours will find the problem more easily. Use OS formatting tools for code.

1 answer

0

This mistake:

Validation failed for query for method

Are you saying that your query is with incorrect syntax.

The point where there is an error in your query is in the lack of space between ?1 and the or. Your query should be generated with an excerpt like this: ?1or. Putting a gap between both will probably solve the problem.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.