@Intercepts( {@Signature(method = "handleResultSets", type = ResultSetHandler.class, args = {Statement.class}) })
public class ResultSetHandlerInterceptor implements Interceptor {
private Logger logger = Logger.getLogger(ResultSetHandlerInterceptor.class);
@Override
public Object intercept(Invocation invocation) throws Throwable {
**想在這裡獲取resultType,如果resultType=“map”時進行相關處理,但是如何獲得resultType呢?**
}
.....
}
已找著解決方法:
ResultSetHandler resultSetHandler = (ResultSetHandler) invocation.getTarget();
//通過java反射獲得mappedStatement屬性值
MappedStatement ms = (MappedStatement)ReflectUtil.getFieldValue(resultSetHandler, "mappedStatement");
List<ResultMap> rms = ms.getResultMaps();
ResultMap rm = rms != null && rms.size() > 0 ? rms.get(0) : null;
String type = rm != null && rm.getType() != null ? rm.getType().getName() :