使用jpa的@Query注解查询数据库中datatime类型数据报错Unknown column 'startTime' in 'where clause'

  • 今天使用 jpa@Query 这个注解查询数据时,sql语句语法出现了错误,记录下来。
  • 我的错误写法是这样的
    @Query(value = "select * from tb where DATE_FORMAT(start_time,'%Y-%m-%d')=DATE_FORMAT(startTime,'%Y-%m-%d')", nativeQuery = true)
    List<PlanExecutionEntity> findByStartTime(Date startTime);
    

你可能感兴趣的:(遇到的问题,java,jpa)