Date type invalid comparison is passed in Mybits: java.util.Date and java.lang.String

An error is reported when the Date type is passed in Mybits

Caused by: java.lang.IllegalArgumentException: invalid comparison: java.util.Date and java.lang.String
When we use the Date type as a parameter to pass in, Mybatis if verification for the Date type cannot verify whether it is an empty string ( '' ), can only verify whether it is empty (null), the newTime in the mapper below is of type Date.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="qlj.bids.dao.BidsMapper">
    <!-- 查询除大文本以外的数据  -->
  <select id="selectBidsList" resultType="qlj.bids.model.Bids"> 
    select title,newTime,id
    from bids
    <where>
        <if test="bids != null">
            <if test="bids.title != null and bids.title !=  '' ">
                    title like  CONCAT("%",#{bids.title},"%") 
            </if>
            <if test="bids.newTime!= null ">
                    AND newTime = #{bids.newTime} 
            </if>
  </select>
</mapper>

Guess you like

Origin blog.csdn.net/Qin_HongKun/article/details/80625339