【发布时间】:2020-04-17 12:27:39
【问题描述】:
这是我在 SQL Server 上的查询:
select count(*) from noleggi
where id_utente = 1 AND id_libro =25 and GETDATE() BETWEEN inizio_prestito AND fine_prestito
使用 JPA Repository 的正确语法是什么?
我试过了:
@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);
并收到此错误:
方法 public abstract java.lang.Long com.finance.biblioteca.repository.NoleggioRepository.countByUtenteIdAndLibroId(java.lang.Long,java.lang.Long,java.time.LocalDate,java.time.本地日期
【问题讨论】:
-
您尝试的方法无效?
-
不,它不起作用
-
您收到错误了吗?没有结果?告诉我们发生了什么。
-
方法 public abstract java.lang.Long com.finance.biblioteca.repository.NoleggioRepository.countByUtenteIdAndLibroId(java.lang.Long,java.lang.Long,java.time.LocalDate)的查询验证失败,java.time.LocalDate)!