2021.4.1

mybatis delete

 

//insert一个用户
int deleteUser(User user);

<delete id="deleteUser" parameterType="int">
delete from mybatis.mybatis where password = #{password};
</delete>

@Test
public void deleteUser(){
SqlSession sqlSession = MybatisUtils.getSqlSession();
UserDao mapper = sqlSession.getMapper(UserDao.class);
int res = mapper.addUser(new User("王二狗","111"));
if(res>0){
System.out.println("插入成功");
}
//提交事务
sqlSession.commit();
sqlSession.close();
}

posted @ 2021-04-01 20:11  不详·Christina  阅读(24)  评论(0编辑  收藏  举报