05DELETE语句

1.mapper配置

<delete id="deleteUserById" parameterType="int">
	delete from user where
	id=#{id}
</delete>

2.java代码

@Test
	public void testDeleteUserById() {
		// 4. 创建SqlSession对象
		SqlSession sqlSession = sqlSessionFactory.openSession();

		// 5. 执行SqlSession对象执行删除
		sqlSession.delete("deleteUserById", 48);

		// 需要进行事务提交
		sqlSession.commit();

		// 7. 释放资源
		sqlSession.close();
	}

猜你喜欢

转载自blog.csdn.net/weixin_37757346/article/details/81332220