我是靠谱客的博主 无聊冰淇淋,这篇文章主要介绍Parameter ‘ids‘ not found. Available parameters are [array, arg0]mabaties在批量删除,接收数组或者集合时,写法是不同的,现在分享给大家,希望可以做个参考。
Parameter ‘ids’ not found. Available parameters are [array, arg0]
mabaties在批量删除,接收数组或者集合时,写法是不同的
接收数组
错误写法
复制代码
1
2int deleteCoinvoiceInfoByCoids(@Param("ids") Long[] ids);
复制代码
1
2
3
4
5
6
7
8
9<update id="deleteCoinvoiceInfoByCoids" > update base_coinvoice_info set del_flag='1' where del_flag='0' and coid in <foreach collection="ids" item="item" index="index" open="(" separator="," close=")"> ${item} </foreach> </update>
正确写法
复制代码
1
2
3
4
5
6
7
8
9<update id="deleteCoinvoiceInfoByCoids" > update base_coinvoice_info set del_flag='1' where del_flag='0' and coid in <foreach collection="array" item="item" index="index" open="(" separator="," close=")"> ${item} </foreach> </update>
接收集合list
错误写法
复制代码
1
2int deleteCoinvoiceInfoByCoids(@Param("ids") List<long> ids);
复制代码
1
2
3
4
5
6
7
8
9<update id="deleteCoinvoiceInfoByCoids" > update base_coinvoice_info set del_flag='1' where del_flag='0' and coid in <foreach collection="ids" item="item" index="index" open="(" separator="," close=")"> ${item} </foreach> </update>
正确写法
复制代码
1
2
3
4
5
6
7
8
9<update id="deleteCoinvoiceInfoByCoids" > update base_coinvoice_info set del_flag='1' where del_flag='0' and coid in <foreach collection="list" item="item" index="index" open="(" separator="," close=")"> ${item} </foreach> </update>
原因
当mybatis传入参数为list集合的时候;mybatis会自动把其封装为一个map;会以“list”作为key;每个元素的值作为value;格式为 Map<“list”,value>
当mybatis传入参数为数组的时候mybatis会自动把其封装为一个map;会以“array”作为key;每个元素的值作为value;格式为Map<“array”,value>
最后
以上就是无聊冰淇淋最近收集整理的关于Parameter ‘ids‘ not found. Available parameters are [array, arg0]mabaties在批量删除,接收数组或者集合时,写法是不同的的全部内容,更多相关Parameter内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复