Eu gostaria de utilizar native querys no lugar de JPQL quando tento usar para fazer o agendamente retornao seguinte erro:2023-08-18T13:58:52.048-03:00 ERROR 7192 --- [nio-8080-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: java.lang.NullPointerException: Cannot invoke "org.hibernate.metamodel.mapping.JdbcMapping.getJdbcValueBinder()" because "jdbcMapping" is null] with root cause
java.lang.NullPointerException: Cannot invoke "org.hibernate.metamodel.mapping.JdbcMapping.getJdbcValueBinder()" because "jdbcMapping" is null
Aqui o codigo do AgendamentoRepository
package med.voll.api.domain.medico;
import java.time.LocalDateTime;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
public interface MedicoRepository extends JpaRepository<Medico, Long> {
Page<Medico> findAllByAtivoTrue(Pageable paginacao);
@Query(value="select * from medicos where especialidade = :especialidade and ativo = 1 and medicos.id not in(select medicos.id from consultas where consultas.data = :data) order by rand() limit 1",nativeQuery = true)
Medico findRandomMedico(Especialidade especialidade, LocalDateTime data);
}