mybaties resultMap可以不写么?

来源:互联网 发布:linux查看网络连接 编辑:程序博客网 时间:2024/06/18 03:44

当然可以了

在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里边啦