MyBatis的Map中放集合对象(为了in操作等)的小提示

MyBatis是SQLMap类型的数据库访问层,使用见:ibatis 开发指南


这里记录一点:为了通用性,需要Map作为Parameter Class,其中有元素filedList是一个List,即MParameter Class为Map,且Map中有集合、数组、Iterator等元素时,出现下面问题:

对于Map中取得集合对象,进行iterate时,如

<select id="findRecordsByFileIdList" parameterClass="java.util.Map" resultMap="EboxFileResultMap">
select id,file_name,parent,physical_symbol,status,type,gmt_modify,length,suffix,owner
from ebox_fs$SHARD_INDEX$
where id in <iterate open="(" close=")" conjunction=",">
#fileIdList[]#
</iterate>
and status > 0 order by type desc, file_name asc, gmt_modify desc
</select>
会报错, Cause: com.ibatis.sqlmap.client.SqlMapException: ParameterObject or property was not a Collection, Array or Iterator.

进行如下配置(红色部分):

<select id="findRecordsByFileIdList" parameterClass="java.util.Map" resultMap="EboxFileResultMap">
select id,file_name,parent,physical_symbol,status,type,gmt_modify,length,suffix,owner
from ebox_fs$SHARD_INDEX$
where id in <iterate open="(" close=")" conjunction="," property="fileIdList">
#fileIdList[]#
</iterate>
and status > 0 order by type desc, file_name asc, gmt_modify desc
</select>



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值