mybatis 如何返回list<map<string,object>>
推荐于2016-02-02 · 知道合伙人互联网行家
关注
展开全部
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();
}
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();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询