java /
正文
Cause: java.lang.IllegalArgumentException: invalid comparison: java.time.LocalDateTime and java.lang
2024-01-13 23:29
2169 浏览
评论(0)
字体大小:
失败:nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang.IllegalArgumentException: invalid comparison: java.sql.Timestamp and java.lang.String
### Cause: java.lang.IllegalArgumentException: invalid comparison: java.sql.Timestamp and java.lang.String
数据库中Time的格式是
`add_time` datetime DEFAULT NULL,
java中Mybatis中的时间格式:
<if test="addTime != null and addTime != '' ">
and add_time <= #{addTime,jdbcType=TIMESTAMP}
</if>
分析错误原因:
mybatis 3.3.0中对时间参数进行比较时: 如果传入的 时间参数 与 空字符串('') 进行对比则会发生异常,在上面的sql中我有对比addTime!='' 这个就会引起异常.所以需要对其删除即可没有异常
修改后:
<if test="addTime != null ">
and add_time <= #{addTime,jdbcType=TIMESTAMP}
</if>
本文发布于程序达人 ,转载请注明出处,谢谢合作
有 0 人认为有用
0 评论
共同学习,写下你的评论
相关热点文章推荐
SpringBoot 2.0 报错: Failed to configure a DataSource: 'url' attribute is not specified and no embe...
程序达人 - chengxudaren.com
一个帮助开发者成长的社区
相关文章