查询代码如下:
<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
判断即可。
来源:oschina
链接:https://my.oschina.net/jenqz/blog/4306887