MyBatis-session-SqlSession
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, 通常用于大的数据集合.

MyBatis-session-SqlSession的更多相关文章
- java.lang.NoClassDefFoundError: org/apache/ibatis/session/SqlSession
在配置一个springmvc+mybatis的项目时,总是有报一个错误: org.springframework.beans.factory.BeanCreationException: Error ...
- 【报错】java.lang.ClassNotFoundException: org.apache.ibatis.session.SqlSession
报错 java.lang.ClassNotFoundException: org.apache.ibatis.session.SqlSession 或者 java.lang.ClassNotFound ...
- 简单探讨spring整合mybatis时sqlSession不需要释放关闭的问题
https://blog.csdn.net/RicardoDing/article/details/79899686 近期,在使用spring和mybatis框架编写代码时,sqlSession不需要 ...
- MyBatis获取SqlSession
package com.ykmimi.dao; import org.apache.ibatis.session.SqlSession; import com.ykmimi.entity.Studen ...
- SSM-MyBatis-10:Mybatis中SqlSession的getMapper()和简单的工具类MyBatisUtils
------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- getMapper的作用,获取到接口,直接通过点的方式调用方法,以免直接手打的方式写错方法名,(强类型的方式) ...
- MyBatis 入门到精通(一) 了解MyBatis获取SqlSession
MyBatis是什么? MyBatis是一款一流的支持自定义SQL.存储过程和高级映射的持久化框架.MyBatis几乎消除了所有的JDBC代码,也基本不需要手工去设置参数和获取检索结果.MyBatis ...
- SSM-MyBatis-07:Mybatis中SqlSession的insert和delete底层到底做了什么
------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- 先点进去看一下insert方法 用ctrl加鼠标左键点进去看 发现是一个接口SqlSession的方法,没有实 ...
- spring中的mybatis的sqlSession是如何做到线程隔离的?
项目中常常使用mybatis配合spring进行数据库操作,但是我们知道,数据的操作是要求做到线程安全的,而且按照原来的jdbc的使用方式,每次操作完成之后都要将连接关闭,但是实际使用中我们并没有这么 ...
- Mybatis的SqlSession运行原理
前言 SqlSession是Mybatis最重要的构建之一,可以简单的认为Mybatis一系列的配置目的是生成类似 JDBC生成的Connection对象的SqlSession对象,这样才能与数据库开 ...
- 使用ThreadLocal管理Mybatis中SqlSession对象
转自http://blog.csdn.net/qq_29227939/article/details/52029065 public class MybatisUtil { private stati ...
随机推荐
- 解决c1xx fatal error C1083 Cannot open source file
在项目开发过程中,遇到一个问题,一个工程B导入另外一个工程A的生产代码,出现这个错误,最后查阅资料发现是文件路径太深,导致文件路径字符超过了217字符. 写了一个测试Demo来验证: 一.新建Win3 ...
- python --- 20 约束 异常处理 MD5 日志
一.类的约束 1.抛出异常 NotImplementedError 2.抽象方法 含有抽象方法的类是抽象类 抽象类中的方法全是抽象方法的是接口 抽象类不能创建对象 二.异常处理 处理完后代码可继 ...
- topcoder srm list
300 305 310 315 320 325 330 335 340 350 360 370 380 390 400 410 415 420 425 430 435 440 445 450 455 ...
- ODAC(V9.5.15) 学习笔记(三)TOraSession(3)
3. 选项 TOraSession的Options有如下内容 名称 类型 说明 CharLength TCharLength 单个字符的长度,缺省0,表示从服务器获取对应的字符集中单个字符长度 Cha ...
- Connections in Galaxy War (逆向并查集)题解
Connections in Galaxy War In order to strengthen the defense ability, many stars in galaxy allied to ...
- IDEA入门及maven配置
idea基本使用 下载安装 idea下载地址 激活方法 上面的失效使用这个 配置SDKs和编译版本 选择jdk 我是主要用于Java开发,因此配置JDK8 配置编码 其他配置 个人配置主题等 注意 与 ...
- pyqt5 eric6 pyqt5-tools
他们都可以通过pip安装,pyqt5-tool提供了qtdesigner,
- 51nod 1624 取余最长路
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1624 题意: 思路:因为一共只有3行,所以只需要确定第一行和第二行的转折 ...
- mathType换行等号对齐
例如: 输入步骤: (1) (2) (3) (4) 事实上,[ctrl+;]表示的是插入了一个对齐标记符.
- EDCheckPrefabRef
using UnityEngine;using System.Collections;using UnityEditor;using UnityEngine.UI;using System.Refle ...