@Test //删除多条-数组
public void testDeleteByArray(){
SqlSession session = factory.openSession();
int[] ids = {4,6};
session.delete(“cn.qq.mapper.PersonMapper.deleteArray”, ids);
session.commit();
}
@Test //删除多条-LIST
public void testDeleteByList(){
SqlSession session = factory.openSession();
List<Integer> _list = new ArrayList<Integer>();
_list.add(4);
_list.add(6);
session.delete(“cn.qq.mapper.PersonMapper.deleteList”, _list);
session.commit();
}
@Test //删除多条 MAP
public void testDeleteByMap(){
SqlSession session = factory.openSession();
Map<String,Object> paraMap = new HashMap<String,Object>();
int[] ids = {4,6};
paraMap.put(“ids”, ids);
session.delete(“cn.qq.mapper.PersonMapper.deleteMap”, paraMap);
session.commit();
}
<!– 删除多条,整形数组 –>
<delete id=”deleteArray” parameterType=”int”>
delete from person
where id in
(
<foreach collection=”array” item=”id” separator=”,”>
#{id}
</foreach>
)
</delete>
<!– 删除多条,LIST集合 –>
<delete id=”deleteList” parameterType=”int”>
delete from person
where id in
<foreach collection=”list” item=”id” open=”(” close=”)” separator=”,”>
#{id}
</foreach>
</delete>
<!– 删除多条,Map , ids 代表map中key –>
<delete id=”deleteMap” parameterType=”map”>
delete from person
where id in
<foreach collection=”ids” item=”id” open=”(” close=”)” separator=”,”>
#{id}
</foreach>
</delete>