本文整理汇总了Java中org.apache.ibatis.executor.SimpleExecutor类的典型用法代码示例。如果您正苦于以下问题:Java SimpleExecutor类的具体用法?Java SimpleExecutor怎么用?Java SimpleExecutor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SimpleExecutor类属于org.apache.ibatis.executor包,在下文中一共展示了SimpleExecutor类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getObject
import org.apache.ibatis.executor.SimpleExecutor; //导入依赖的package包/类
@Override
public SqlSessionFactory getObject() throws Exception {
SqlSessionFactory sqlSessionFactory = super.getObject();
if (sqlSessionFactory instanceof DefaultSqlSessionFactory)
return proxy(sqlSessionFactory, methodInvocation -> {
if (methodInvocation.getMethod().getName().equals("openSession")) {
SqlSession session = (SqlSession) methodInvocation.proceed();
if (session instanceof DefaultSqlSession) {
DefaultSqlSession defaultSqlSession = (DefaultSqlSession) session;
Executor executor = (Executor) ReflectionUtils.getFieldValue(defaultSqlSession, "executor");
if (executor instanceof CachingExecutor) {
CachingExecutor cachingExecutor = (CachingExecutor) executor;
SimpleExecutor ex = (SimpleExecutor) ReflectionUtils.getFieldValue(cachingExecutor, "delegate");
System.out.println("ex-> " + ex.getClass().getName());
ReflectionUtils.setDeclaredFieldValue(cachingExecutor, "delegate", proxy(ex, invocation -> {
System.out.println("method->" + invocation.getMethod());
return invocation.proceed();
}));
}
}
return session;
}
return methodInvocation.proceed();
});
return sqlSessionFactory;
}
示例2: session
import org.apache.ibatis.executor.SimpleExecutor; //导入依赖的package包/类
public SqlSession session(Connection conn) {
Transaction transaction = new ManagedTransaction(conn, false);
SimpleExecutor excutor = new SimpleExecutor(configuration, transaction);
return new DefaultSqlSession(configuration, excutor);
}
示例3: getSqlSession
import org.apache.ibatis.executor.SimpleExecutor; //导入依赖的package包/类
public SqlSession getSqlSession(Connection conn) throws SQLException {
ManagedTransaction transaction = new ManagedTransaction(conn, false);
SimpleExecutor excutor = new SimpleExecutor(configuration, transaction);
return new DefaultSqlSessionHelper(configuration, excutor);
}