1.MybatisMapperProxy.invoke() 的Mapper代理对象, 走缓存的调用cachedInvoker(method).invoke(proxy, method, args, sqlSession);使用sqlSession执行
2.sqlSession 调用 Plugin的一个拦截器 MybatisPlusInterceptor
3.拦截器中执行Excutor的 MybatisCachingExecutor.doQuery() ,并没走二级缓存,再委托调用另外一个实现 MybatisSimpleExecutor.doQuery() 第一次请求也没走一级缓存,里面调用StatementHandler.query()
4.StatementHandler 的一个实现:RoutingStatementHandler.query(),再委托调用另外一个实现 PreparedStatementHandler.query() ,
5. 调用Statement 的一个实现ShardingPreparedStatement.execute(),内部使用PreparedStatementExecutor#execute
6.PreparedStatementExecutor#execute中最终使用父类AbstractStatementExecutor#executeCallback
7.里头使用SQLExecuteTemplate#execute()
8.交给ExecutorEngine#execute(),并使用并行执行ExecutorEngine#parallelExecute
9.其中先执行异步asyncExecute,再执行syncExecute
10.SQLExecuteCallback#execute0
其中sharding 获取连接的位置:
org.apache.shardingsphere.shardingjdbc.executor.StatementExecutor#init
org.apache.shardingsphere.sharding.execute.sql.prepare.SQLExecutePrepareTemplate#getSQLExecuteGroups
获取连接
org.apache.shardingsphere.shardingjdbc.jdbc.adapter.AbstractConnectionAdapter#getConnections