1.SqlSession下的四大对象
Executor、StatementHandler、ParameterHandler、ResultSetHandler
StatementHandler的作用是使用数据库的Statement(PreparedStatement)执行操作
ParameterHandler是用来处理SQL参数的
ResultSetHandler是进行数据集的封装返回处理的
2.mybatis中有3中执行器:
SIMPLE——简易执行器,默认
REUSE——是一种能够执行重用预处理语句的执行器
BATCH ——执行器重用语句和批量更新,批量专用的执行器
private SqlSession openSessionFromDataSource(ExecutorType execType, TransactionIsolationLevel level, boolean autoCommit) { Transaction tx = null; DefaultSqlSession var8; try { Environment environment = this.configuration.getEnvironment(); TransactionFactory transactionFactory = this.getTransactionFactoryFromEnvironment(environment); tx = transactionFactory.newTransaction(environment.getDataSource(), level, autoCommit); Executor executor = this.configuration.newExecutor(tx, execType, autoCommit); var8 = new DefaultSqlSession(this.configuration, executor); } catch (Exception var12) { this.closeTransaction(tx); throw ExceptionFactory.wrapException("Error opening session. Cause: " + var12, var12); } finally { ErrorContext.instance().reset(); } return var8; }
原文地址:https://www.cnblogs.com/lvjygogo/p/9531507.html
时间: 2024-10-01 22:39:22