Java 如何在Spring Boot中编辑查询?

Java 如何在Spring Boot中编辑查询?,java,spring,postgresql,spring-boot,Java,Spring,Postgresql,Spring Boot,我有一个存储库,我需要找到id和日期的数据 我写这段代码: @Query(value = "select * from cheer.coordinate where childid = ?1 and CAST(creationdate as DATE) = ?2", nativeQuery = true) List<Coordinate> findAllByChildidAndDate(@Param("childid") Long childid, @Param("date") St

我有一个存储库,我需要找到id和日期的数据

我写这段代码:

@Query(value = "select * from cheer.coordinate where childid = ?1 and CAST(creationdate as DATE) = ?2",
nativeQuery = true)
List<Coordinate> findAllByChildidAndDate(@Param("childid") Long childid, @Param("date") String date);
@Query(value=“select*from cheel.coordinate,其中childid=?1,CAST(creationdate as DATE)=?2”,
nativeQuery=true)
列出FindAllByChildAndDate(@Param(“childid”)长childid,@Param(“date”)字符串日期);
但当我尝试使用它时,我会出现以下错误:

org.postgresql.util.PSQLException:错误:运算符不存在:日期=字符变化


如何修复它?

在postgres控制台中工作的示例:
从cheel.coordinate中选择*,其中childid=1,CAST(creationdate as DATE)='30-01-2020'
不要将日期作为字符串传递,而是将其作为
LocalDate
的实例传递,因此
@Param(“date”)LocalDate date)