mybatis-mapper执行过程

2017-12-25  本文已影响0人  7d29b558374e

请先看事务那篇
在看mapper的执行过程
我们知道mapper是采用动态代理,先看下对应的InvocationHandler

public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        if(Object.class.equals(method.getDeclaringClass())) {
            try {
                return method.invoke(this, args);
            } catch (Throwable var5) {
                throw ExceptionUtil.unwrapThrowable(var5);
            }
        } else {
            MapperMethod mapperMethod = this.cachedMapperMethod(method);
            return mapperMethod.execute(this.sqlSession, args);
        }
    }
image.png

继续执行到SqlSessionInterceptor的invoke方法

SqlSessionUtils.getSqlSession(SqlSessionTemplate.this.sqlSessionFactory, SqlSessionTemplate.this.executorType, SqlSessionTemplate.this.exceptionTranslator);
上一篇 下一篇

猜你喜欢

热点阅读