mybatis mapper在使用in查询的时候报一个比较错误
时间: 2020-06-10来源:OSCHINA
前景提要
查询代码如下: <select id="getDeviceIds" resultMap="deviceId"> select id, device_id from prod_freezer <where> <if test="companyId != '' and companyId != null"> and company_id = #{companyId} </if> <if test="ids!= '' and ids != null"> and id in <foreach collection="ids" item="item" index="index" open="(" separator="," close=")"> #{item} </foreach> </if> </where> </select>
报如下的错 Cause: java.lang.IllegalArgumentException: invalid comparison: java.util.ArrayList and java.lang.String
原来if test的表达式写的不对,传入ids是ArrayList,不能当成字串比较,直接用 ids!=null 判断即可。

科技资讯:

科技学院:

科技百科:

科技书籍:

网站大全:

软件大全:

热门排行