return method.invoke(this, args); }
finalClass> declaringInterface = findDeclaringInterface(proxy, method);
finalMapperMethod mapperMethod = newMapperMethod(declaringInterface, method, sqlSession); final Objectresult = mapperMethod.execute(args);
if (result ==null && method.getReturnType().isPrimitive()&& !method.getReturnType().equals(Void.TYPE)) {
thrownewBindingException("Mapper method '" + method.getName() + "'(" + method.getDeclaringClass() + ") attempted toreturn null from a method with a primitive return type ("
+ method.getReturnType() + ")."); }
return result; }
[java] view plaincopy
public Objectexecute(Object[] args) { Objectresult = null;
if(SqlCommandType.INSERT == type) { Objectparam = getParam(args);
result= sqlSession.insert(commandName, param); } elseif(SqlCommandType.UPDATE == type) {
Object param = getParam(args); result= sqlSession.update(commandName, param);
} elseif(SqlCommandType.DELETE == type) { Objectparam = getParam(args);
result= sqlSession.delete(commandName, param); } elseif(SqlCommandType.SELECT == type) {
if (returnsVoid &&resultHandlerIndex != null) { executeWithResultHandler(args);
} elseif (returnsList) { result = executeForList(args);
} elseif (returnsMap) { result = executeForMap(args);
} else { Object param = getParam(args);
result = sqlSession.selectOne(commandName, param); }
} else { thrownewBindingException("Unknown execution method for: " + commandName);
} return result;
}
[java] view plaincopy
public Listquery(MappedStatement ms, Object parameterObject, RowBounds rowBounds,ResultHandler resultHandler) throws SQLException { if (ms != null) {
Cachecache = ms.getCache(); if (cache != null) {
flushCacheIfRequired(ms); cache.getReadWriteLock().readLock().lock();
try { if (ms.isUseCache() && resultHandler ==null) {
CacheKey key = createCacheKey(ms, parameterObject, rowBounds); final List cachedList = (List)cache.getObject(key);
if (cachedList != null) { returncachedList;
} else { List list = delegate.query(ms,parameterObject, rowBounds, resultHandler);
tcm.putObject(cache,key, list); return list;
} } else {
returndelegate.query(ms,parameterObject, rowBounds, resultHandler); }
} finally { cache.getReadWriteLock().readLock().unlock();
} }
} returndelegate.query(ms,parameterObject, rowBounds, resultHandler);
}
[java] view plaincopy
public ListdoQuery(MappedStatement ms, Object parameter, RowBounds rowBounds,ResultHandler resultHandler) throws SQLException { Statementstmt = null;
try { Configuration configuration = ms.getConfiguration();
StatementHandler handler = configuration.newStatementHandler(this, ms,parameter, rowBounds,resultHandler); stmt =prepareStatement(handler);
returnhandler.query(stmt, resultHandler); } finally {
closeStatement(stmt); }
}
[java] view plaincopy
publicStatementHandler newStatementHandler(Executor executor, MappedStatementmappedStatement, ObjectparameterObject, RowBounds rowBounds, ResultHandler resultHandler) {
StatementHandler statementHandler = newRoutingStatementHandler(executor, mappedStatement,parameterObject,rowBounds, resultHandler); statementHandler= (StatementHandler) interceptorChain.pluginAll(statementHandler);
returnstatementHandle