当我尝试调用 JPA 函数时,这条语句出现错误:“:”处或附近的语法错误 public interface BcaTestRepository extends CrudRepository<InBodyBCA, Long> { @Query(value = "SELECT * FROM in_body_bca bca WHERE person_id = :personId " + "AND to_timestamp(bca.datetimes::text, 'YYYYMMDDHH24MISS') BETWEEN :startRange AND :endRange", nativeQuery = true) List<InBodyBCA> findAllByPersonId(@Param("personId") Long personId, @Param("startRange") LocalDateTime startRange, @Param("endRange") LocalDateTime endRange);但在 PgAdmin 中查询工作正常SELECT id, to_timestamp(datetimes::text, 'YYYYMMDDHH24MISS') as dt FROM in_body_bca WHERE to_date(datetimes::text, 'YYYYMMDDHH24MISS')BETWEEN '2018-05-07' AND '2019-05-07' ORDER BY to_date(datetimes::text, 'YYYYMMDDHH24MISS') DESC ;
1 回答
慕码人8056858
TA贡献1803条经验 获得超6个赞
您在这里使用双冒号:bca.datetimes::text
。JPA 会寻找text
变量名。
你需要逃避它:
bca.datetimes\\:\\:text
添加回答
举报
0/150
提交
取消