当然可以了
在mapper中定义一个借口 返回值是map
然后 再xml中可以这样定义 resultType="HashMap"
例子
<select id="selectOrderStatus" parameterType="java.lang.String" resultType="java.util.HashMap" > SELECT SUM(aa.co) totalAccount, MAX(CASE fs WHEN 1 THEN co ELSE 0 END) AS "orderToPayAccount", MAX(CASE fs WHEN 2 THEN co ELSE 0 END) AS "orderToShipAccount", MAX(CASE fs WHEN 3 THEN co ELSE 0 END) AS "orderToReceiveAccount" FROM( SELECT finish_status fs, COUNT(id) co FROM shopping_order <where> <if test="buyerCode != null and buyerCode !=''" > buyer_code= #{buyerCode,jdbcType=VARCHAR} </if> </where> GROUP BY finish_status) aa </select>
取好别名就自动映射到map里边啦
本文介绍如何在MyBatis中使用复杂SQL查询并返回HashMap类型的数据结构,通过示例展示如何设置resultType属性来获取特定字段的数据。

4490

被折叠的 条评论
为什么被折叠?



