MyBatis-opensession
来源:互联网 发布:数据挖掘 答案 韩家炜 编辑:程序博客网 时间:2024/05/29 12:51
创建sqlsession经过了以下几个主要步骤:1) 从配置中获取Environment;2) 从Environment中取得DataSource;3) 从Environment中取得TransactionFactory;4) 从DataSource里获取数据库连接对象Connection;5) 在取得的数据库连接上创建事务对象Transaction;6) 创建Executor对象(该对象非常重要,事实上sqlsession的所有操作都是通过它完成的);7) 创建sqlsession对象。SqlSessionFactory factory=new SqlSessionFactoryBuilder().build(is); SqlSession session = factory.openSession(); SqlSession接口 类: DefaultSqlSessionFactory--> private final org.apache.ibatis.session.Configuration configuration; --> public DefaultSqlSessionFactory (org.apache.ibatis.session.Configuration configuration) --> public org.apache.ibatis.session.SqlSession openSession()-->openSession(boolean b); SqlSessionManager-->startManagedSession -->public org.apache.ibatis.session.SqlSession openSession(boolean autoCommit) -->openSession()解析完配置文件之后,配置文件中的所有信息就存储到了Configuration对象中了,在创建SqlSessionFactory对象时将Configuration做为SqlSessionFactory对象的一个属性,通过调用SqlSessionFactory的openSession(...),openSession()有很多重载方法,创建SqlSession对象只能通过openSession()和这些重载方法@Override public SqlSession openSession() { return openSessionFromDataSource(configuration.getDefaultExecutorType(), null, false); } 底层代码://IntelliJ API Decompiler stub source generated from a class file从类文件生成的intellij存根源文件//Implementation of methods is not available无法实现方法package org.apache.ibatis.session;public interface SqlSessionFactory { org.apache.ibatis.session.SqlSession openSession(); org.apache.ibatis.session.SqlSession openSession(boolean b); org.apache.ibatis.session.SqlSession openSession(java.sql.Connection connection); org.apache.ibatis.session.SqlSession openSession(org.apache.ibatis.session.TransactionIsolationLevel transactionIsolationLevel); org.apache.ibatis.session.SqlSession openSession(org.apache.ibatis.session.ExecutorType executorType); org.apache.ibatis.session.SqlSession openSession(org.apache.ibatis.session.ExecutorType executorType, boolean b); org.apache.ibatis.session.SqlSession openSession(org.apache.ibatis.session.ExecutorType executorType, org.apache.ibatis.session.TransactionIsolationLevel transactionIsolationLevel); org.apache.ibatis.session.SqlSession openSession(org.apache.ibatis.session.ExecutorType executorType, java.sql.Connection connection); org.apache.ibatis.session.Configuration getConfiguration();}
阅读全文
0 0
- MyBatis-opensession
- MyBatis--打开session(openSession)
- openSession
- opensession - threadlocal
- hibernate openSession and getCurrentSEssion
- getCurrentSession()与openSession() 区别
- openSession和getCurrentSession区别
- hibernate openSession() 与 getCurrentSession()
- hibernate openSession和getCurrentSession
- openSession与getCurrentSession
- openSession() getCurrentSession() 区别
- getCurrentSession与openSession区别
- openSession和getCurrentSession
- openSession和getCurrentSession 比较
- Hibernate getCurrentSession openSession
- openSession、getCurrentSession区别
- getCurrentSession与openSession详解
- getCurrentSession与openSession区别
- rabbimq 集群部署说明
- 剑指Offer笔记—— 从尾到头打印链表 重建二叉树
- vuejs的v-for遍历、v-bind动态改变值、v-if进行判断
- 我的广告
- 让exe文件开机自启动
- MyBatis-opensession
- 在Java中动态传参调用Python脚本
- 常见设计模式
- vim命令总结
- mysql 级联删除
- Spring+Quartz踩到的坑
- canvas画圆弧
- MyBatis--打开session(openSession)
- HTML-px、em、rem、vw、vh 的相应理解