public RowMapper getRowMapper(StatementMetaData modifier) {
RowHandler rowHandler = modifier.getAnnotation(RowHandler.class);
if (rowHandler != null) {
if (rowHandler.rowMapper() != RowHandler.ByDefault.class) {
try {
RowMapper rowMapper = rowHandler.rowMapper().newInstance();
if (logger.isInfoEnabled()) {
logger.info("using rowMapper " + rowMapper + " for " + modifier);
}
return rowMapper;
} catch (Exception ex) {
throw new BeanInstantiationException(rowHandler.rowMapper(), ex.getMessage(),
ex);
}
}
}
//
Class<?> returnClassType = modifier.getMethod().getReturnType();
Class<?> rowType = getRowType(modifier);
// BUGFIX: SingleColumnRowMapper 处理 Primitive Type 抛异常
if (rowType.isPrimitive()) {
rowType = ClassUtils.primitiveToWrapper(rowType);
}
// 根据类型创建 RowMapper
RowMapper rowMapper;
// 返回单列的查询的(或者返回只有2列的Map类型查询的)
if (TypeUtils.isColumnType(rowType)) {
if (returnClassType == Map.class) {
rowMapper = new MapEntryColumnRowMapper(modifier, rowType);