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