mybatis的執行流程
阿新 • • 發佈:2017-07-13
updating 9.png obj object upd manager urn .exe registry
MapperRegistry中保存了Mapper對應的動態代理對象
MapperProxy 生成對應的代理對象,代理的interface是SqlSession,實現有兩種SqlSessionManager和DefaultSqlSession。默認是DefaultSqlSession。
DefaultSqlSession的實在獲取Session的時候生成的。
sessionFactory.openSession();返回的是DefaultSqlSession。
具體的執行是由StatementHandler執行。
public int update(String statement, Object parameter) {
int var4;
try {
this.dirty = true;
MappedStatement ms = this.configuration.getMappedStatement(statement);
var4 = this.executor.update(ms, this.wrapCollection(parameter));
} catch (Exception var8) {
throw ExceptionFactory.wrapException("Error updating database. Cause: " + var8, var8);
} finally {
ErrorContext.instance().reset();
}
return var4;
}
this.executor中得到上次獲取的executor對象
mybatis的執行流程