本文整理汇总了Java中org.apache.ibatis.executor.CachingExecutor类的典型用法代码示例。如果您正苦于以下问题:Java CachingExecutor类的具体用法?Java CachingExecutor怎么用?Java CachingExecutor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CachingExecutor类属于org.apache.ibatis.executor包,在下文中一共展示了CachingExecutor类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getObject
import org.apache.ibatis.executor.CachingExecutor; //导入依赖的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: intercept
import org.apache.ibatis.executor.CachingExecutor; //导入依赖的package包/类
@Override
public Object intercept(Invocation invocation) throws Throwable {
CachingExecutor executor = (CachingExecutor) invocation.getTarget();
return null;
}