SqlSeesion:
作为Mybatis工作的顶层的API接口,作为会话访问,完成增删改查功能
Executor:
Mybatis的核心执行器,负责SQL动态语句生成,查询缓存和维护
StatementHandler:
parameterHandler:
负责JDBC和Statement的交互,包括Statement参数设置
TypeHandler:负责JDBC与javaType之间数据转换,
1.对Statement对象设置 特定的参数
2.对Statement返回的结果集,取出特定的列
ResultSetHandler:
将JDBC返回的结果集 resultSet,转换成List
//读取配置文件,读成字节输入流,还没开始解析
Inputstream inputstream = Resources.getResourceAsStream("mybatisconfig.xml");
//这⼀⾏代码正是初始化⼯作的开始。 SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(inputStream);
// 1.我们最初调⽤的build public SqlSessionFactory build (InputStream inputStream){ //调⽤了重载⽅法 return build(inputStream, null, null); } // 2.调⽤的重载⽅法 public SqlSessionFactory build (InputStream inputStream, String environment, Properties properties){ try { // XMLConfigBuilder是专⻔解析mybatis的配置⽂件的类 XMLConfigBuilder parser = new XMLConfigBuilder(inputstream, environment, properties); //这⾥⼜调⽤了⼀个重载⽅法。parser.parse()的返回值是Configuration对象 return build(parser.parse()); } catch (Exception e) { throw ExceptionFactory.wrapException("Error building SqlSession.", e) }
SqlSession:
public class DefaultSqlSession implements SqlSession { private final Configuration configuration; private final Executor executor; }