mybaits 学习笔记 (删除数据) 二
1、单个删除
配置xml文件:
<delete id="deleteUser" parameterType="int">
delete from user where id=#{_parameter}
</delete>
DAO层调用:
sqlSession.delete("User.deleteUser",id);
2、批量删除
xml配置:
<delete id="deleteUsers" parameterType="java.util.List">
delete from message where id in(
<foreach collection="list" item="item" separator=",">
#{item}
</foreach>
)
</delete>
DAO层调用:
sqlSession.delete("User.deleteUsers",ids);