Mybatis通过映射直接返回,有时候我们需要其元数据或映射前的ResultSet值,Mybatis中有拦截器类
@Intercepts({@Signature(type = ResultSetHandler.class, method =
"handleResultSets", args = {Statement.class})}) public class Demoimplements
Interceptor { @Override public Object intercept(Invocation invocation) throws
Throwable{ List<Map> actual = new ArrayList<Map>(); Object[] args =
invocation.getArgs(); Statement statement = (Statement) args[0]; ResultSet rs =
statement.getResultSet(); while (rs == null) { if (statement.getMoreResults())
{ rs = statement.getResultSet(); } else { if (statement.getUpdateCount() == -1)
{ break; } } } ..... } @Override public Object plugin(Object target) { return
Plugin.wrap(target, this); } @Override public void setProperties(Properties
properties) { //To change body of implemented methods use File | Settings |
File Templates. } }