=============== MyBatis更新记录 =============== public interface StudentDao { ... // 修改学生 public int mod(Student student); ... } ... update t_student set name=#{name}, gender=#{gender}, age=#{age} where number=#{number} ... public class StudentDaoTest { ... // 测试修改学生 @Test public void testMod() { try { // SQL会话 SqlSession session = new SqlSessionFactoryBuilder() .build(Resources.getResourceAsStream("mybatis-config.xml")) .openSession(); // 数据访问对象 StudentDao dao = session.getMapper(StudentDao.class); // 修改学生 int rows = dao.mod(new Student(0, "1001", "貂蝉", "女", 19)); // 受影响的行数应为1 assertEquals(1, rows); // 提交事务 session.commit(); } catch (IOException e) { e.printStackTrace(); } } ... } 例程:HelloMyBatis