今天进行下面得查询得时候,
总是报:Cause: java.lang.IllegalArgumentException: invalid comparison: java.time.LocalDate and java.lang.String,提示不能将LocalDate类型与String类型进行比较,
刚开始一直在检查<if>下得条件,寻思是不是类型写的不对,
后来才发现是<if>标签中得判断问题,
具体原因是因为
startDate!='' 这种判断条件,在mybatis种,不能将日期时间类型与''字符串进行比较,所以导致上述报错,
解决办法,把判断条件中得''字符串判断删除即可。
错误代码:
<select id="selectSeatOrderNumMonth"
resultType="com.pjk.RemoteSeatOrderMonthStatEntity">
select
org_no inst_no,
org_name inst_name,
seat_code,
seat_name,
count(*) order_number
from
order_wide_table
<where>
<if test="startDate!=null && startDate!='' && endDate!=null" && endDate!=''>
create_time >= #{startDate}
and
create_time <= #{endDate}
</if>
</where>
group by
org_no,
org_name,
seat_code,
seat_name;
</select>
正确代码:
<select id="selectSeatOrderNumMonth"
resultType="com.pjk.RemoteSeatOrderMonthStatEntity">
select
org_no inst_no,
org_name inst_name,
seat_code,
seat_name,
count(*) order_number
from
order_wide_table
<where>
<if test="startDate!=null && endDate!=null" >
create_time >= #{startDate}
and
create_time <= #{endDate}
</if>
</where>
group by
org_no,
org_name,
seat_code,
seat_name;
</select>
标签:code,name,遇到,no,seat,日期,time,mybatis,org From: https://blog.51cto.com/u_16205743/8285695