public Executor newExecutor(Transaction transaction, ExecutorType executorType) { executorType = executorType == null ? this.defaultExecutorType : executorType; executorType = executorType == null ? ExecutorType.SIMPLE : executorType; Object executor; if (ExecutorType.BATCH == executorType) { executor = new BatchExecutor(this, transaction); } else if (ExecutorType.REUSE == executorType) { executor = new ReuseExecutor(this, transaction); } else { executor = new SimpleExecutor(this, transaction); } if (this.cacheEnabled) { executor = new CachingExecutor((Executor)executor); } Executor executor = (Executor)this.interceptorChain.pluginAll(executor); return executor; }
那我们这里得到的Executor经过判断就是SimpleExecutor了。
⑤在 var8 = new DefaultSqlSession(this.configuration, executor, autoCommit);中,我们要去获取SqlSession的实现类了DefaultSqlSession,终于到了最后。源码如下:
public DefaultSqlSession(Configuration configuration, Executor executor, boolean autoCommit) { this.configuration = configuration; this.executor = executor; this.dirty = false; this.autoCommit = autoCommit; }
这样,SqlSession的实现类DefaultSqlSession就拥有了配置对象信息,拥有了执行器信息,那么它就知道怎么去处理sql语句了。看看,这个configuration对象贯穿始终,核心的核心,源码是不会骗人的。
2、在private SqlSession openSessionFromConnection(ExecutorType execType, Connection connection)方法中,它的源码如下: