Mybatis-基本增删改查
查询数据: List<User> userList = sqlSession.selectList("userMapper.findAll"); <select id="findAll" resultType="com.itheima.domain.User"> select * from User </select> 添加数据: sqlSession.insert("userMapper.add", user); <insert id="add" parameterType="com.itheima.domain.User"> insert into user values(#{id},#{username},#{password}) </insert> 修改数据: sqlSession.update("userMapper.update", user); <update id="update" parameterType="com.itheima.domain.User"> update user set username=#{username},password=#{password} where id=#{id} </update> 删除数据: sqlSession.delete("userMapper.delete",3); <delete id="delete" parameterType="java.lang.Integer"> delete from user where id=#{id} </delete>