mybatis返回HashMap<Long,List<Long>>

原始数据:

SHOP_IDACCOUNT_ID
2192
2193

需求是:根据店铺id获取店员帐号列表


mybatis配置代码:

    <resultMap class="java.util.HashMap" id="AccountMap" groupBy="shopId">
		<result column="SHOP_ID" property="shopId" jdbcType="BIGINT" />
		<result property="accountList" javaType="java.util.ArrayList" resultMap="SHOP_ACCOUNT_REF.accountResult" /> 
    </resultMap>
    <resultMap id="accountResult" class="java.lang.Long">
		<result column="ACCOUNT_ID" property="accountId" jdbcType="BIGINT" />
    </resultMap> 
    
    <!-- 提供给IM的接口:根据店铺id获取店铺帐号列表-->
    <select id="selectAccountIdsByShopId" resultMap="AccountMap" parameterClass="list">
		 select SHOP_ID,ACCOUNT_ID from SHOP_ACCOUNT_REF 
		 where IS_DEL=0 and SHOP_ID in
		 <iterate open="(" close=")" conjunction="," >  
                   #[]#  
                 </iterate>
    </select>
上面代码中shopId是key,accountList是value.


dao操作代码:

public HashMap<Long, List<Long>> selectAccountIdsByShopId(List<Long> shopIds)
			throws DataAccessException {
		return (HashMap<Long, List<Long>>)sqlMapClient.queryForMap("SHOP_ACCOUNT_REF.selectAccountIdsByShopId", shopIds, "shopId","accountList");
	}




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值