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> |
进行如下配置(红色部分):
| <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> |
本文详细介绍了在MyBatis开发中遇到的问题,即在使用Map作为参数类型时,如何正确配置iterate标签来处理集合参数,避免出现SqlMapException错误。
898

被折叠的 条评论
为什么被折叠?



