ibatis 查询返回结果为map

来源:互联网 发布:比较好的c语言教材 编辑:程序博客网 时间:2024/06/05 03:29

ibatis里面result只有3种,resultMap,resultClass,resultSetType,没有resultType(mybatis的)

研究了下手册,发现返回map的方式如下:

<resultMap class="java.util.HashMap" id="getCountStoreMstr">
    <result property="countBalanceQty" column="BALANCE_QTY_S"/>
    <result property="countReserveQty" column="RESERVE_QTY_S"/>
    </resultMap>
     <select id="StoreItemView-getCountStoreMstr" parameterClass="java.util.Map"  resultMap="getCountStoreMstr">
   SELECT SUM(SI.BALANCE_QTY) BALANCE_QTY_S 
   ,SUM(SI.RESERVE_QTY) RESERVE_QTY_S
   FROM STOREITEM SI 
   WHERE SI.MATERIALITEMMSTR_ID =#materialItemMstrId#
    </select>

resultMap对应的class必须是实体类,所以这里用HashMap,不能用Map,或者你自己做一个实体类(我们公司常用的方法)

原创粉丝点击