在上面的博客中,做的是大部分的 DQL的操作
DML操作:
UserMapper接口:
package com.liubo.mapper;
import com.liubo.domain.User;
public interface UserMapper {
//增
public int inselUser(User user);
//删
public int deleteUser(User user);
//改
public int updateUser(User user);
}
UserMapper.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.liubo.mapper.UserMapper">
<insert id="inselUser" parameterType="user">
insert into test_user values(null,#{name},#{password})
</insert>
<update id="updateUser" parameterType="user">
update test_user set name = #{name},password = #{password} where id = #{id}