bug0002:PostgreSQL整合Mybatis日期查询格式问题

1. 背景

项目中很多模块都需要根据时间区间进行查询数据

2. 报错情况

使用String 格式时间进行MybatisSQL查询报错日期类型转换异常
使用Date类型则不会报错

3. 解决方案

在PostgreSQL整合Mybatis需要进行时间范围查询书写SQL时,在String格式日期后加上::timestamp

<select id="selectBetweenTime" resultType="com.example.demo.qo.SysUserQO">
	   select * from sys_user where create_time  &gt;= #{beginTime}::timestamp and create_time &lt;= #{endTime}::timestamp
</select>
posted @ 2022-04-28 11:45  因心光  阅读(904)  评论(0编辑  收藏  举报