The SqlSession instance is the most powerful in MyBatis.

It is where you'll find all of the methods to execute statements, commit or rollback transactions and acquire mapper instances.

There are over 20 methods on the SqlSession class.

  • 1. Statement Execution

These methdos are used to execute SELECT, INSERT, UPDATE and DELETE statemnets that are defined in your SQL Mapping XML files, There are pretty self expanatory, each takes the ID(defined in <select> in XXXMapper.xml) of the statement and the Parameter Object,which can be a primitive (auto-boxed or wrapper), a JavaBean, a POJO or a Map.

  • 2. selectOne和selectList的区别:

selectOne必须返回exactly one object or null(none).

如果超过一个,就会抛出异常.

如果不知道多少个对象,使用selectList.

如果你像检查一个对象的存在, 最好返回一个count(0 or 1).

selectMap 是一个特殊的情况.他是被设计用来convert a list of results into a Map based on one of the properties in the resulting objects.(不懂) .

因为不是所有的语句都需要参数,这些方法也被重载为不需要参数对象的版本.

最后,还有三个高级版本的select方法.它们允许你限制返回行数的范围, or provide custom result handing logic, 通常用于大的数据集合.

最新文章

  1. 转:CentOS/Debian/Ubuntu一键安装LAMP(Apache/MySQL/PHP)环境
  2. 机器学习之K-近邻算法
  3. [转]oracle 分析函数over
  4. mysql远程连接命令
  5. 重温Servlet学习笔记--request对象
  6. ubuntu下配置jdk
  7. php变量判断为空的几种方法
  8. 【IHttpHandler】了解 IHttpHandler
  9. perl连接mysql(转载)
  10. Linux 命令整理 —— 用户管理
  11. 数字图像处理-----主成成分分析PCA
  12. Matlab聚类分析[转]
  13. docker 创建镜像
  14. iOS纯代码制作欢迎界面——UIScrollView, UIPageControl, UIImageView,UIButton, NSTimer
  15. C#如何生成缩略图、水印
  16. Linux使用命令 笔记
  17. MySQL 常用使用语句
  18. Entity Framework应用:使用EF的DataBase First模式实现数据库的增删改查
  19. NOIP2016 “西湖边超萌小松鼠” 模拟赛
  20. 使用Spring发送Email

热门文章

  1. ldap集成rabbitmq
  2. UVa Live 4670 Dominating Patterns - Aho-Corasick自动机
  3. Delphi xe5 编译报environment.proj错误的解决
  4. Bootstrap3基础 disabled 多选框 鼠标放在方框与文字上都出现禁止 标识
  5. 清理sqlserver 2012 日志文件
  6. shell中使用echo输出时如何指定颜色
  7. 数论+矩阵快速幂|斐波那契|2014年蓝桥杯A组9-fishers
  8. hihoCoder week20 线段树的区间修改
  9. Perceptual Losses for Real-Time Style Transfer and Super-Resolution and Super-Resolution 论文笔记
  10. R语言可视化学习笔记之添加p-value和显著性标记--转载