栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

MyBatis入门级(增删改查)

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

MyBatis入门级(增删改查)

1.接口 StudentMapper

package com.tty.mybatis.dao;

import com.tty.mybatis.pojo.Student;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

public interface StudentMapper {

    // 还可以这样写节省时间
    @Select("select `id`,`name`,`student_sex` from student where `id` = #{id}")
    //查询 id 查询学生
    public Student retrieveStudentById(Integer id);
    //增加
    public void addStudent(Student student);
    //更新
    public void updateStudentName(Map map);
    // 普通写法 :public void updateStudentName(@Param("id") Integer id, @Param("newName") String newName);
    // 删除
    public void deleteStudent(Integer id);
}


2.学生映射配置文件 StudentMapper.xml