目录

mybatis日期格式与字符串不匹配bug

目录

mybatis日期格式与字符串不匹配bug

异常特征:java.lang.IllegalArgumentException: invalid comparison: java.time.LocalDateTime and java.lang.String

### Error updating database.  Cause: java.lang.IllegalArgumentException: invalid comparison: java.time.LocalDateTime and java.lang.String
### The error may exist in file [E:\Projects\02.VitalLink\Server\vital-link\vital-server\target\classes\mapper\doctor\DoctorAccountMapper.xml]
### The error may involve cn.edu.hactcm.vitallink.doctor.mapper.DoctorAccountMapper.updateInfo
### The error occurred while executing an update

  <if test="updateTime != null and updateTime != ''">update_time = #{updateTime}</if>

改为

<if test="updateTime != null">update_time = #{updateTime}</if>

官方:

LocalDateTime是Java 8时间类型,与空字符串’‘类型不兼容(MyBatis OGNL表达式限制)

根据MyBatis 3.5官方文档第14.2节,时间类型字段应仅做null检查