public List<XXXBean> getXXXBeanList(List<String> list);
<select id="getXXXBeanList" resultType="XXBean"> select 字段... from XXX where id in <foreach item="item" index="index" collection="list" open="(" separator="," close=")"> #{item} </foreach> </select>
foreach 最后的效果是select 字段… from XXX where id in (‘1’,’2’,’3’,’4’)
多参数传递之注解方式示:
例子:
1
public AddrInfo getAddrInfo(@Param("corpId")int corpId, @Param("addrId")int addrId);
xml配置这样写:
1 2 3 4
<select id="getAddrInfo" resultMap="com.xxx.xxx.AddrInfo"> SELECT * FROM addr__info where addr_id=#{addrId} and corp_id=#{corpId} </select>
<select id="getSysInfo" parameterType="java.util.Map" resultType="SysWeb"> select t.sysSiteId, t.siteName, t1.mzNum as siteTagNum, t1.mzName as siteTag, t.url, t.iconPath from TD_WEB_SYSSITE t left join TD_MZ_MZDY t1 on t1.mzNum = t.siteTag and t1.mzType = 10 WHERE t.siteTag = #{siteTag } and t.sysSiteId not in <foreach collection="list" item="item" index="index" open="(" close=")" separator=","> #{item} </foreach> </select>