spring + ibatis的Dao层架构中一条sql的执行过程:
- execute在sql执行过程中的位置
- 开启回话 SqlMapClientTemplate.openSession();
- 设置事务 SqlMapClientTemplate->SqlMapExecutorDelegate.new UserProvidedTransaction();
- 执行 SqlMapClientTemplate.doInSqlMapClient()
- 关闭连接 springCon.close()
- 获取连接的时机:
- 预编译 SqlExecutor.prepareStatement
- 代理方法中 TransactionAwareInvocationHandler->DataSourceUtils.doGetConnection();
获取连接不是开启事务的时候,而是在真正需要的时候。