1、  普通映射

2、 @Select("select * from mybatis_Student where id=#{id}")

3、 public Student getStudent(int id);

4、 @Insert("insert into mybatis_Student (name, age, remark, pic,grade_id,address_id) values (#{name},#{age},#{remark}, #{pic},#{grade.id},#{address.id})")

5、 public int insert(Student student);

6、 @Update("update mybatis_Student set name=#{name},age=#{age} where id=#{id}")

7、 public int update(Student student);

8、 @Delete("delete from mybatis_Student where id=#{id}")

9、 public int delete(int id);

2、结果集映射

@Select("select * from mybatis_Student")

@Results({

@Result(id=true,property="id",column="id"),

@Result(property="name",column="name"),

@Result(property="age",column="age")

})

public List<Student> getAllStudents();

3、关系映射

3.1、一对一

@Select("select * from mybatis_Student")

@Results({

@Result(id=true,property="id",column="id"),

@Result(property="name",column="name"),

@Result(property="age",column="age"),

@Result(property="address",column="address_id",one=@One(select="com.skymr.mybatis.mappers.AddressMapper.getAddress"))

})

public List<Student> getAllStudents();

3.2、一对多

@Select("select * from mybatis_grade where id=#{id}")      @Results({          @Result(id=true,column="id",property="id"),          @Result(column="grade_name",property="gradeName"),       @Result(property="students",column="id",many=@Many(select="com.skymr.mybatis.mappers.Student2Mapper.getStudentsByGradeId"))      })

public Grade getGrade(int id);

最新文章

  1. Nginx的启动脚本(Centos)
  2. win7、linux安装使用pip、mitmproxy
  3. 设计模式之美:Composite(组合)
  4. sql语句查询数据库表结构信息
  5. [SAP ABAP开发技术总结]数据输入输出转换、小数位/单位/货币格式化
  6. 安卓 Dialogs(对话框)
  7. iOS开发中遇到的头文件找不到的问题解决办法
  8. nginx服务器绑定域名和设置根目录
  9. SQL日语词汇
  10. IOS 第三方开源库记录
  11. B. Fixed Points
  12. myeclipse中自己手动配置maven
  13. NLP 苏图南 打破自我设限 突破自我—在线播放—优酷网,视频高清在线观看
  14. geodocker-geomesa安装指南
  15. Aooms_微服务基础开发平台实战_002_工程构建
  16. linux下用ctrl+r快速搜索history命令
  17. 「Android」SurfaceFlinger分析
  18. 逻辑运算的妙用-Single Number
  19. CORS jsonp
  20. Linux-lvm逻辑卷管理和提示丢失pv物理卷

热门文章

  1. java的多线程和并发库
  2. @property &amp; @synthesize &amp; @dynamic 及相关属性作用探究
  3. Model验证简单易懂
  4. c# Reverse()的两点用法
  5. chrome浏览器页面获取绑定返回顶部动画事件插件
  6. 树莓派3B+学习笔记:7、挂载exfat格式U盘
  7. MIPI调试经验(转载)
  8. STM32 Startup**.s文件中使用的 __main C函数入口
  9. 第一篇随笔, 正在做 ESP32 , STM32 , 树莓派 RaspberryPi 的创客工具
  10. 使用xadmin更新数据时,报错expected string or bytes-like object