This is my query on SQL Server:
select count(*) from noleggi
where id_utente = 1 AND id_libro =25 and GETDATE() BETWEEN inizio_prestito AND fine_prestito
Which is the correct syntax using JPA Repository?
I tried this:
@Query(value = "SELECT COUNT(n) from Noleggio n " +
"WHERE n.libroId = ?1 AND n.utenteId=?2 AND CURRENT_DATE() BETWEEN n.inizioPrestito AND n.finePrestito")
Long countByUtenteIdAndLibroId(Long idLibro, Long idUtente, LocalDate inizioPrestito, LocalDate finePrestito);
And received this error:
Validation failed for query for method public abstract java.lang.Long com.finance.biblioteca.repository.NoleggioRepository.countByUtenteIdAndLibroId(java.lang.Long,java.lang.Long,java.time.LocalDate,java.time.LocalDate