Mybatis中的Executor(策略模式)

Executor是Mybatis的核心执行器接口,包括SimpleExecutor、BatchExecutor、CachingExecutor和ReuseExecutor等不同策略实现。SimpleExecutor用于普通执行,ReuseExecutor和BatchExecutor都重用PreparedStatement,但BatchExecutor支持批量更新。CachingExecutor则结合了缓存功能。

Mybatis中的Executor(策略模式)

抽象统一接口:Excutor
适配器:BaseExecutor


不同的实现策略:SimpleExecutor | BatchExecutor | CachingExecutor | ClosedExecutor | ReuseExecutor

  • SimpleExecutor 普通的执行器
  • ReuseExecutor 重用预处理语句(PreparedStatement)
  • BatchExecutor 重用预处理语句(PreparedStatement)且 执行批量更新
package org.apache.ibatis.executor;

import java.sql.SQLException;
import java.util.List;
import org.apache.ibatis.cache.CacheKey;
import org.apache.ibatis.cursor.Cursor;
import org.apache.ibatis.mapping.BoundSql;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.transaction.Transaction;

public interface Executor {
	ResultHandler NO_RESULT_HANDLER = null;
	
	int update(MappedStatement var1,Object var2) throws SQLException;

	<E> List<E> query(MappedStatement var1,Object var2,RowBounds var3,ResultHandler var4,CacheKey var5,BoundSql var6) throws SQLException;

	<E> List<E> query(MappedStatement var1,Object var2,RowBounds var3,ResultHandler var4) throws SQLException;
	
	<E> Cursor<E> queryCursor();


}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值