invalid comparison: java.util.ArrayList and java.lang.String解决

报错:

Caused by: org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang.IllegalArgumentException: invalid comparison: java.util.ArrayList and java.lang.String
### Cause: java.lang.IllegalArgumentException: invalid comparison: java.util.ArrayList and java.lang.String

原因:

我的orderStates是一个数组格式,我此处判断的是 orderStates!=null,故报错。应该改成orderState.size()>0

<if test="orderStates !=null and orderStates!=''">
AND State in
<foreach collection="orderStates" item="state" open="(" separator="," close=")" >
#{state}
</foreach>
</if>

正确书写如下:

<if test="orderStates !=null and orderStates.size > 0">
AND State in
<foreach collection="orderStates" item="state" open="(" separator="," close=")" >
#{state}
</foreach>
</if>
上一篇:SQL格式化插件—SQL Pretty Printer


下一篇:laui中文件上传使用