这个错误是由于在SQL语句中,试图将Date类型的postingDateString类型的type进行比较而导致的。为了解决这个问题,你可以按照以下方式修改代码:

  1. selectVmiListForQuantity方法的参数类型由DateString改为String类型,然后在方法内部将其转换为Date类型。
List<VmiMaterialDocument> selectVmiListForQuantity(@Param("postingDate") String postingDate, @Param("type") String type) {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    Date date = null;
    try {
        date = format.parse(postingDate);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    
    // 调用SQL语句并传入转换后的日期参数
    // ...
}
  1. 修改XML文件中的SQL语句,将postingDate参数的比较方式改为与String类型的type参数进行比较。
<if test="postingDate != null and postingDate != ''">
    DATE_FORMAT(PostingDate, '%Y-%m') = DATE_FORMAT(#{postingDate}, '%Y-%m')
</if>

这样就可以解决这个问题了。请注意,如果postingDate的格式不是yyyy-MM-dd,则需要相应地修改SimpleDateFormat的格式。

ListVmiMaterialDocument selectVmiListForQuantityParampostingDate Date postingDate Paramtype String type; select id=selectVmiListForQuantity resultType=orgjeecgmodulesodsMaterialDocumentServiceentityVm

原文地址: https://www.cveoy.top/t/topic/i8A2 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录