mybatis 如何返回list<map<string,object>>

如题所述

Mapper里面返回List,就是说Mapper里面的方法声明是
public List
dao、service层也作相应修改,改为返回List<Map<String,Object>>
<mapper namespace="com.brkc.epolice.mysql.dao.OnlineStatMapper" >
<select id="selectOnlineRateCurrent" resultType="java.util.HashMap" >
SELECT count(*) value, c. NAME label, ifnull(b.device_status, 0) device_status
FROM td01_device a
LEFT OUTER JOIN td06_device_status b ON a.id = b.device_id
LEFT OUTER JOIN td05_dd_device_status c ON c.ID = ifnull(b.device_status, 0)
GROUP BY ifnull(b.device_status, 0), c. NAME
ORDER BY device_status
</select>

</mapper>
public interface OnlineStatMapper {
public List<Map<String, Object>> selectOnlineRateCurrent();
}
温馨提示:内容为网友见解,仅供参考
第1个回答  2014-10-28
拆分:将map拆分成List<KeyValue>结构,KeyValue: String, Object本回答被提问者和网友采纳