一些IBatis使用的例子

2021年09月15日 阅读数:3
这篇文章主要向大家介绍一些IBatis使用的例子,主要内容包括基础应用、实用技巧、原理机制等方面,希望对大家有所帮助。

public List<GiveMyDistributorBean> queryDistriWithNoGoods(Long parentId, List<Long> goodIds, int skip, int max) {java

Map<String, Object> param = new HashMap<String, Object>();ide

param.put("parentId", parentId);this

param.put("goodsId", goodIds);spa

List<GiveMyDistributorBean> list = distriShopEditDao.getPublicDAO().selectBySqlMapId(ip

"selectDistributorByParentAndGoods", param, skip, max);ci

return list;get

}it


IBatis代码:io

select *class

   FROM TB_UNITE_DS_DISTRIBUTOR_EDIT A

   WHERE A.PARENT_ID=#parentId#

 AND A.DISTRIBUTOR_ID  NOT IN (SELECT DISTRIBUTOR_ID FROM TB_UNITE_DS_GOODS G WHERE G.GOODS_ID IN

 <iterate property="goodsId" conjunction="," open="(" close=")">

             #goodsId[]#

 </iterate>

 )


======================

后台查询代码:

HashMap hMap = (HashMap) this.payinstDao.getPublicDAO().selectFirstRowBySqlMapId("getUnCheckPayInstCountByOrdersId", objParam);

int payNum = ((java.math.BigDecimal) hMap.get("COUNTER")).intValue();


IBatis代码:

<select id="getUnCheckPayInstCountByOrdersId" resultClass="java.util.HashMap"  > 

     SELECT COUNT(*) COUNTER FROM tb_unite_order_payinst A WHERE A.ORDER_CODE = #orderCode:VARCHAR# 

     AND A.CHECK_RESULT in ('00','11','22','33','77') AND A.PAYINST_ID != #payinstId:NUMERIC# 

   </select>