zoukankan      html  css  js  c++  java
  • Mybatis使用注解进行增删改查

    // 增
    public
    interface StudentMapper{ @Insert("insert into student (stud_id, name, email, addr_id, phone)values(#{studId},#{name},#{email},#{address.addrId},#{phone})") int insertStudent(Student student); } public interface StudentMapper{ @Insert("insert into student (name,email,addr_id,phone)values(#{name},#{email},#{address.addrId},#{phone})") @Options(useGeneratedKeys=true,keyProperty="studId") int insertStudent(Student student); } public interface StudentMapper{ @Insert("insert into student (name,email,addr_id,phone)values(#{name},#{email},#{address.addrId},#{phone})") @SelectKey(statement="select stud_id_seq.nextval from dual",keyProperty="studId",resultType=int.calss,before=true) int insertStudent(Student student); }
    // 改 @Update(
    "update students set name=#{name},email=#{email}") int updateStudent(Student student);
    // 删 @Delete(
    "delete form students where stud_id=#{studId}") int deleteStudent(int studId)
    // 查 @Select(
    "select name,email,phone from students where stud_id=#{studId}") Student findStudentById(Integer studId);

    推荐使用xml文件进行配置,方面后续修改容易

  • 相关阅读:
    前端基础知识1
    mysql作业
    mysql了解知识点
    mysql3
    数据库作业2
    循环结构经典题型
    计算1
    猜数字游戏
    css的显示
    定位和position定位
  • 原文地址:https://www.cnblogs.com/wangzh1guo/p/9998985.html
Copyright © 2011-2022 走看看