Mybatis源码之SimpleExecutor
2016-01-13 21:03
309 查看
/** * @author Clinton Begin */ public class SimpleExecutor extends BaseExecutor { public SimpleExecutor(Configuration configuration, Transaction transaction) { super(configuration, transaction); } @Override public int doUpdate(MappedStatement ms, Object parameter) throws SQLException { Statement stmt = null; try { //获得配置文件对象 Configuration configuration = ms.getConfiguration(); //获得statementHandler里面有statement,来处理 StatementHandler handler = configuration.newStatementHandler(this, ms, parameter, RowBounds.DEFAULT, null, null); stmt = prepareStatement(handler, ms.getStatementLog()); //最终是一个statement进行处理 return handler.update(stmt); } finally { closeStatement(stmt); } } @Override public <E> List<E> doQuery(MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) throws SQLException { Statement stmt = null; try { //获得配置文件对象 Configuration configuration = ms.getConfiguration(); //获得statementHandler里面有statement,来处理 StatementHandler handler = configuration.newStatementHandler(wrapper, ms, parameter, rowBounds, resultHandler, boundSql); //获得statement stmt = prepareStatement(handler, ms.getStatementLog()); //最终是一个statement进行处理 return handler.<E>query(stmt, resultHandler); } finally { closeStatement(stmt); } } @Override public List<BatchResult> doFlushStatements(boolean isRollback) throws SQLException { return Collections.emptyList(); } private Statement prepareStatement(StatementHandler handler, Log statementLog) throws SQLException { Statement stmt; Connection connection = getConnection(statementLog); stmt = handler.prepare(connection); handler.parameterize(stmt); return stmt; } }
相关文章推荐
- Mybatis源码之SimpleExecutor
- 实体类实现Parcelable接口详解
- 贝叶斯 算法 实例 scala
- Mybatis源码之SimpleExecutor
- 旋转、平移、缩放和透明度渐变的补间动画
- 在PPAPI插件中创建本地窗口
- [转]maven插件的开发
- Android 选择时间,并排序
- leetcode笔记:Bulls and Cows
- 进制转换并打印
- 总结2015年,展望2016
- C#中的单例模式
- Android性能优化典范(四)
- iOS学习之路-应用管理之九宫格
- 浅谈C++中的虚析构函数
- 对数组里的字典进行数字字母排序
- 页面载入完毕后表单获得焦点
- codevs 3116 高精度练习之加法
- 【杭电oj】1096 - A+B for Input-Output Practice (VIII)
- 7. Reverse Integer