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> |