1.SqlSessionFactoryBuilder (构造器)
- 会根据配置或者代码来生成SqlSessionFactory
2.SqlSessionFactory (工厂接口)
- 以后他来生成SqlSession
3.SqlSession (会话)
- 一个既可以发送SLQ执行返回结果,也可以获取Mapper的接口
4.SQL Mapper (映射器)
- 负责发送SQL 去执行,并返回结果。
使用MyBatis 肯定是要生成 SqlSessionFactory
1.通过读取xml 配置文件用SqlSessionFactoryBuilder 生成
2.通过代码用 SqlSessionFactoryBuilder 生成
SqlSessionFactory的作用?
* sqlSessionFactory 唯一的作用就是生产 MyBatis的核心接口对象SqlSession
* 一般采用单例模式处理它
SqlSession的作用?
* SqlSession 的作用类似一个JDBC中的 Connection 对象代表着一个连接资源的启用。
具体
- 获取Mapper 接口
- 发送 SQL语句 给数据库
- 控制数据库事务
- commit()