3
respostas

erro ao inicializar projeto com nova classe de cancelamento

Bom dia.

Após realizar as alterações para o cancelamento, esta retornando erro abaixo

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'consultaController': Unsatisfied dependency expressed through field 'agendaDeConsultas': Error creating bean with name 'agendaDeConsultas': Unsatisfied dependency expressed through field 'medicoRepository': Error creating bean with name 'medicoRepository' defined in com.github.paulopcrp.healthcare.api.domain.medico.MedicoRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Could not create query for public abstract com.github.paulopcrp.healthcare.api.domain.medico.Medico com.github.paulopcrp.healthcare.api.domain.medico.MedicoRepository.escolherMedicoAleatorioLivreNaData(com.github.paulopcrp.healthcare.api.domain.medico.Especialidade,java.time.LocalDateTime); Reason: Validation failed for query for method public abstract com.github.paulopcrp.healthcare.api.domain.medico.Medico com.github.paulopcrp.healthcare.api.domain.medico.MedicoRepository.escolherMedicoAleatorioLivreNaData(com.github.paulopcrp.healthcare.api.domain.medico.Especialidade,java.time.LocalDateTime) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:716) ~[spring-beans-6.0.11.jar:6.0.11] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:696) ~[spring-beans-6.0.11.jar:6.0.11] at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:145) ~[spring-beans-6.0.11.jar:6.0.11]

3 respostas

Caused by: java.lang.IllegalArgumentException: Validation failed for query for method public abstract com.github.paulopcrp.healthcare.api.domain.medico.Medico com.github.paulopcrp.healthcare.api.domain.medico.MedicoRepository.escolherMedicoAleatorioLivreNaData(com.github.paulopcrp.healthcare.api.domain.medico.Especialidade,java.time.LocalDateTime) at org.springframework.data.jpa.repository.query.SimpleJpaQuery.validateQuery(SimpleJpaQuery.java:100) ~[spring-data-jpa-3.1.2.jar:3.1.2] at org.springframework.data.jpa.repository.query.SimpleJpaQuery.(SimpleJpaQuery.java:70) ~[spring-data-jpa-3.1.2.jar:3.1.2] at org.springframework.data.jpa.repository.query.JpaQueryFactory.fromMethodWithQueryString(JpaQueryFactory.java:60) ~[spring-data-jpa-3.1.2.jar:3.1.2] at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$DeclaredQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:170) ~[spring-data-jpa-3.1.2.jar:3.1.2] at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:252) ~[spring-data-jpa-3.1.2.jar:3.1.2] at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:95) ~[spring-data-jpa-3.1.2.jar:3.1.2] at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lookupQuery(QueryExecutorMethodInterceptor.java:111) ~[spring-data-commons-3.1.2.jar:3.1.2] ... 61 common frames omitted Caused by: java.lang.IllegalArgumentException: org.hibernate.query.SemanticException: A query exception occurred [select * from Medico m where m.ativo = 1 and m.especialidade = :especialidade and m.id not in (select c.medico.id from Consulta c where c.data = :data) order by rand() limit 1

Caused by: org.hibernate.query.SemanticException: A query exception occurred [select * from Medico m where m.ativo = 1 and m.especialidade = :especialidade and m.id not in (select c.medico.id from Consulta c where c.data = :data) order by rand() limit 1

Oi!

Altere o ínicio da sua query para: select m from Medico m where m.ativo = true