我们上篇文章讲到了查询方法里面的doQuery方法,这里面就是调用JDBC的API了,其中的逻辑比较复杂,我们这边文章来讲,先看看我们上篇文章分析的地方
SimpleExecutor
1 public <E> List<E> doQuery(MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) throws SQLException { 2 Statement stmt = null; 3 try { 4 Configuration configuration = ms.getConfiguration(); 5 // 创建 StatementHandler 6 StatementHandler handler = configuration.newStatementHandler(wrapper, ms, parameter, rowBounds, resultHandler, boundSql); 7 // 创建 Statement 8 stmt = prepareStatement(handler, ms.getStatementLog()); 9 // 执行查询操作 10 return handler.<E>query(stmt, resultHandler); 11 } finally { 12 // 关闭 Statement 13 closeStatement(stmt); 14 } 15 }