/**
* @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
原创归田归田 博主文章分类:Mybatis入门及源码学习 ©著作权
©著作权归作者所有:来自51CTO博客作者归田归田的原创作品,请联系作者获取转载授权,否则将追究法律责任

提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
一文带你理解透MyBatis源码
MyBatis几乎成为了Java开发人员必须深入掌握的框架技术,今天,我们就一起来深入分析MyBatis源码。
sql 增删改查 数据库 JDK JVM -
Mybatis执行SimpleExecutor(三)
SimpleExecutor通过类名可以看出,它是一个简单的执行类,并不会做一些处理就执
mybatis executor SimpleExecutor sql ide -
myBatis源码之Configuration
/** * @author Clinton Begin */ //mybatis配置文件对应的类,包含了配置
mybatis Configuration 数据 java xml -
myBatis源码之XMLConfigBuilder
/** * @author Clinton Begin */public class XMLConfigBuilder extends BaseBuilder { privder(R
mybatis XMLConfigBuilder xml 子节点 sed -
mybatis源码之SimpleStatementHandler
/** * @author Clinton Begin */public class SimpleStatementHandler extends BaseSta
SimpleStatementHandl sql ide sql语句 -
myBatis源码学习之SqlSessionFactoryBuilder
/* * Builds {@link SqlSession} instances. * *//** * @author Clinton Begin */public class SqlSessi, n
SqlSessionFactoryBui mybatis sql xml 配置文件 -
myBatis源码学习之SqlSessionFactory
/** * Creates an {@link SqlSesion} out of a connection or a DataSource * * @author Cli
SqlSessionFactory mybatis sql 不可重复读 缓存 -
myBatis源码学习之SqlSession
/** * @author Clinton Begin */public class DefaultSqlSession implements SqlSession
SqlSession mybatis sql ide 数据 -
Mybatis源码学习之TypeHandler
ORM框架最重要功能是将面向对象方法中的对象和关系型数据库中的表关联了起来,在关联过法:主
mybatis TypeHandler IntegerTypeHandler sql ide