<selectid="selectByUserIdAndStatus"resultType="cn.cb.demo.domain.UserInfo"> select * from user_info where user_id=#{param1} and status=#{param2}
</select>
<selectid="selectByUserIdAndStatus"resultType="cn.cb.demo.domain.UserInfo"> select * from user_info where user_id=#{userId} and status=#{status}
</select>
<select id="selectByUserIdAndStatusMap" resultType="cn.cb.demo.domain.UserInfo">
select * from user_info where user_id=#{userId} and status=#{status}
</select>
<selectid="selectList"resultMap="userResultMap"> select * from user_info where status=1
and user_id in
<foreachcollection="list"item="item"open="("separator=","close=")" > #{item}
</foreach></select>
数组传参
这种方式类似List传参,依旧使用foreach语法。
Mapper方法如下:
List<UserInfo> selectList( String[] userIds);
XML如下:
<selectid="selectList"resultMap="userResultMap"> select * from user_info where status=1
and user_id in
<foreachcollection="array"item="item"open="("separator=","close=")" > #{item}
</foreach></select>