在Student.xml中添加如下代码:
<delete id="deleteStudentById" parameterClass="int">
delete
from student
where id=#id#
</delete>
在junit中进行测试:
1 @Test
2 public void deleteStudent() throws Exception{//根据Id删除学生
3 Reader reader=Resources.getResourceAsReader("SqlMapConfig.xml");//读取总配置文件
4 SqlMapClient sqlmapclient=SqlMapClientBuilder.buildSqlMapClient(reader);//创建SqlMapClient来操作数据库
5 reader.close();
6 sqlmapclient.delete("deleteStudentById",5);//调用我们写在xml中的sql语句
7 }
查看数据库,已成功删除: