MyBatis Mapper.xml入参List使用in函数问题
作者:孤er尽悲欢绝
文章主要讲述了在使用MyBatis的Mapper.xml文件时,如何正确地在in函数中使用List作为入参,作者强调了完整拷贝<if>...</if>格式的重要性,并指出稍微的改动就会导致错误
MyBatis Mapper.xml入参List使用in函数
解决方案
正确使用in
函数。
一定要完整拷贝整个<if>...</if> 格式也一定要一样不然还是会报错
<select id="getFrontSeaList" resultType="com.xxx.common.vo.clue.ClueSeaListVo"> select c.id, c.oid, c.name, c.phone, c.customer_type, c.industry, c.source, c.create_time from clue c where 1=1 and c.sales_uid = 0 <if test="oidList != null"> and c.oid in <foreach collection="oidList" item="oidList" index="index" open="(" separator="," close=")"> #{oidList} </foreach> </if> and c.is_delete = 0 </select>
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。