mybatis之异常invalid comparison: java.util.Date and java.lang.String(时间判断空串出现异常情况)

笑着哭i 提交于 2020-10-29 11:58:09

查询条件是时间类型:因为mybatis 3.3.0中对于时间参数进行比较时的一个bug. 如果拿传入的时间类型参数与空字符串''进行对比判断则会引发异常. 所以在上面的代码中去掉该判断, 只保留非空判断就正常了。不然报下面的异常:

 

后端的xml代码如下:

<!-- 查询外聘教师档案信息 -->
    <select id="select" resultMap="ExternalTeacherMap"
        parameterType="com.ly.education.teacher.api.dto.ExternalTeacherDto">
        select
        <include refid="Base_Column_SELECT_List" />,
        dw.DWMC as PYDWMC,
        from T_SZGL_WPJSXX wpjs
        left join T_GGZY_DWXX dw
        	on dw.DW_ID = wpjs.pydw
        <where>
        <if test="teacherId != null and teacherId != '' ">
          and  wpjs.JGH like concat(concat('%',#{teacherId,jdbcType=VARCHAR}),'%')
        </if>
        <if test="teacherName != null and teacherName != '' ">
          and  wpjs.XM like concat(concat('%',#{teacherName,jdbcType=VARCHAR}),'%')
        </if>
        <if test="teacherDepartment != null and teacherDepartment != '' ">
          and  wpjs.PYDW = #{teacherDepartment,jdbcType=VARCHAR}
        </if>
        <if test="teacherOldName != null and teacherOldName != '' ">
          and  wpjs.CYM = #{teacherOldName,jdbcType=VARCHAR}
        </if>
        <if test="teacherSpellName != null and teacherSpellName != '' ">
          and  wpjs.XMPY = #{teacherSpellName,jdbcType=VARCHAR}
        </if>
        <if test="teacherEnglishName != null and teacherEnglishName != '' ">
          and  wpjs.YWMC = #{teacherEnglishName,jdbcType=VARCHAR}
        </if>
        <if test="teacherIDCode != null and teacherIDCode != '' ">
          and  wpjs.SFZJLXM = #{teacherIDCode,jdbcType=VARCHAR}
        </if>
        <if test="teacherIDNumber != null and teacherIDNumber != '' ">
          and  wpjs.SFZJH = #{teacherIDNumber,jdbcType=VARCHAR}
        </if>
        <if test="teacherSexCode != null and teacherSexCode != '' ">
          and  wpjs.XB = #{teacherSexCode,jdbcType=VARCHAR}
        </if>
        <if test="teacherBirthday != null">
          and  wpjs.CSRQ = #{teacherBirthday,jdbcType=DATE}
        </if>
        <if test="teacherNationalityCode != null and teacherNationalityCode != '' ">
          and  wpjs.MZM = #{teacherNationalityCode,jdbcType=VARCHAR}
        </if>
        <if test="teacherCountryCode != null and teacherCountryCode != '' ">
          and  wpjs.GJDQM = #{teacherCountryCode,jdbcType=VARCHAR}
        </if>
        <if test="teacherNativeCode != null and teacherNativeCode != '' ">
          and  wpjs.JG = #{teacherNativeCode,jdbcType=VARCHAR}
        </if>
        <if test="teacherPoliticalCode != null and teacherPoliticalCode != '' ">
          and  wpjs.ZZMMM = #{teacherPoliticalCode,jdbcType=VARCHAR}
        </if>
        <if test="teacherStartDay != null and teacherStartDay != '' ">
          and  wpjs.CJNY = #{teacherStartDay,jdbcType=VARCHAR}
        </if>
        <if test="teacherOrganizationCode != null and teacherOrganizationCode != '' ">
          and  wpjs.BZLBM = #{teacherOrganizationCode,jdbcType=VARCHAR}
        </if>
        <if test="teacherProfessionalTechnologyCode != null and teacherProfessionalTechnologyCode != '' ">
          and  wpjs.ZYJSZWM = #{teacherProfessionalTechnologyCode,jdbcType=VARCHAR}
        </if>
        <if test="teacherCadrePostCode != null and teacherCadrePostCode != '' ">
          and  wpjs.GBZWMCM = #{teacherCadrePostCode,jdbcType=VARCHAR}
        </if>
        <if test="teacherPostLevelCode != null and teacherPostLevelCode != '' ">
          and  wpjs.ZWJBM = #{teacherPostLevelCode,jdbcType=VARCHAR}
        </if>
        <if test="teacherEducationCode != null and teacherEducationCode != '' ">
          and  wpjs.ZGXLM = #{teacherEducationCode,jdbcType=VARCHAR}
        </if>
        <if test="teacherDegreeCode != null and teacherDegreeCode != '' ">
          and  wpjs.ZGXWM = #{teacherDegreeCode,jdbcType=VARCHAR}
        </if>
        <if test="teacherCurrentStateCode != null and teacherCurrentStateCode != '' ">
          and  wpjs.JZGDQZTM = #{teacherCurrentStateCode,jdbcType=VARCHAR}
        </if>
        <if test="teacherOrganizationSign != null and teacherOrganizationSign != '' ">
          and  wpjs.SFZB = #{teacherOrganizationSign,jdbcType=VARCHAR}
        </if>
        <if test="teacherOnDutySign != null and teacherOnDutySign != '' ">
          and  wpjs.SFZG = #{teacherOnDutySign,jdbcType=VARCHAR}
        </if>
        <if test="teacherCampusId != null and teacherCampusId != '' ">
          and  wpjs.CZXQ = #{teacherCampusId,jdbcType=VARCHAR}
        </if>
        <if test="teacherTelephone != null and teacherTelephone != '' ">
          and  wpjs.LLDH = #{teacherTelephone,jdbcType=VARCHAR}
        </if>
        <if test="teacherEmail != null and teacherEmail != '' ">
          and  wpjs.DZYX = #{teacherEmail,jdbcType=VARCHAR}
        </if>
        <if test="teacherEnterDate != null and teacherEnterDate != ''">
          and  wpjs.RXRQ = #{teacherEnterDate,jdbcType=DATE}
        </if>
        <if test="teacherLeaveDate != null">
          and  wpjs.LXRQ = #{teacherLeaveDate,jdbcType=DATE}
        </if>
        <if test="teacherRemark != null and teacherRemark != '' ">
          and  wpjs.BZ = #{teacherRemark,jdbcType=VARCHAR}
        </if>
        <if test="creator != null and creator != '' ">
          and  wpjs.CJR = #{creator,jdbcType=VARCHAR}
        </if>
        <if test="createTime != null and createTime != '' ">
          and  wpjs.CJSJ = #{createTime,jdbcType=DATE}
        </if>
        <if test="editor != null and editor != '' ">
          and  wpjs.ZHXGR = #{editor,jdbcType=VARCHAR}
        </if>
        <if test="editTime != null and editTime != '' ">
          and  wpjs.ZHXGSJ = #{editTime,jdbcType=DATE}
        </if>
        </where>
    </select>

  

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!