在Student.xml中添加:

    <update id="updateStudent" parameterClass="Student">
update student
set name=#name#,
score=#score#
where id=#id#
</update>

进行单元测试:

 1     @Test
2 public void updateStudent() throws Exception{//更新学生
3 Reader reader=Resources.getResourceAsReader("SqlMapConfig.xml");//读取总配置文件
4 SqlMapClient sqlmapclient=SqlMapClientBuilder.buildSqlMapClient(reader);//创建SqlMapClient来操作数据库
5 reader.close();
6 Student student=new Student();
7 student.setId(1);
8 student.setName("Billy");
9 student.setScore(70.5f);
10 sqlmapclient.update("updateStudent",student);//调用我们写在xml中的sql语句
11     }

查看数据库:

ibatis基础(六):修改实体对象




相关文章:

  • 2021-07-11
  • 2021-10-04
  • 2021-09-27
  • 2021-07-18
  • 2021-08-21
  • 2021-06-30
  • 2021-11-21
猜你喜欢
  • 2021-10-02
  • 2021-11-23
  • 2022-01-05
  • 2022-01-24
  • 2021-12-06
  • 2021-05-26
  • 2023-02-05
相关资源
相似解决方案