我是靠谱客的博主 奋斗人生,最近开发中收集的这篇文章主要介绍ibatis 中传入list对象,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

 

1.ibatis中直接传入一个集合形如:List<MdSeller>

 

<select id="query" parameterClass="java.util.HashMap"
      resultClass="com.baosight.b2c.yo.domain.OrdOrder">
   SELECT
    *
   FROM
   yiyao_b2c.ord_order as oo join
   (select * from (
   <isNotEmpty prepend=" " property="orderSourceList">
        <iterate property="orderSourceList" conjunction="union" open="(" close=")">       
      SELECT  JD_ORDER_ID as jdOrderId,
         CONCAT(AVG(UPDATE_TIME),JD_ORDER_ID) orderColumn
         FROM yiyao_b2c.ord_order
         where IS_DELETE=0 and  ORDER_SOURCE = #orderSourceList[]#
      <isNotEmpty prepend=" AND " property="jdOrderId">
         JD_ORDER_ID like concat('%',#jdOrderId#,'%')
      </isNotEmpty>
      <isNotEmpty prepend=" AND " property="status">
         STATUS = #status#
      </isNotEmpty>
      <isNotEmpty prepend=" AND " property="partnerId">
         PARTNER_ID = #partnerId#
      </isNotEmpty>
      <isNotEmpty prepend=" AND " property="orderSource">
         ORDER_SOURCE = #orderSource#
      </isNotEmpty>
      
      <isNotEmpty prepend=" AND " property="orderTimeStartDate">
         ORDER_TIME &gt;= #orderTimeStartDate#
      </isNotEmpty>
      <isNotEmpty prepend=" AND " property="orderTimeEndDate">
         ORDER_TIME &lt;= concat(#orderTimeEndDate#,${iplat.time.suffix})
      </isNotEmpty>
      <isNotEmpty prepend=" AND " property="receiver">
         RECEIVER like concat('%',#receiver#,'%')
      </isNotEmpty>
      <isNotEmpty prepend=" AND " property="mobile">
         MOBILE like concat('%',#mobile#,'%')
      </isNotEmpty>
      GROUP BY JD_ORDER_ID
         </iterate>
   </isNotEmpty>
   ) as aa)orderColumnTable
        on oo.JD_ORDER_ID=orderColumnTable.jdOrderId 
   where oo.IS_DELETE=0
   <isNotEmpty prepend=" AND " property="id">
      oo.ID = #id#
   </isNotEmpty>
   <isNotEmpty prepend=" AND " property="orderNo">
      oo.ORDER_NO like concat('%',#orderNo#,'%')
   </isNotEmpty>
  <isNotEmpty prepend=" AND " property="mySeller"> 
        oo.SELLER_ID  in 
      <iterate open="(" close=")" conjunction=",">           
          #mySeller[].id#        
            </iterate>
    </isNotEmpty>
   <isNotEmpty prepend=" AND " property="jdOrderId">
      oo.JD_ORDER_ID like concat('%',#jdOrderId#,'%')
   </isNotEmpty>
   <isNotEmpty prepend=" AND " property="kjtSosysNo">
      oo.KJT_SOSYS_NO like concat('%',#kjtSosysNo#,'%')
   </isNotEmpty>
   <isNotEmpty prepend=" AND " property="status">
      oo.STATUS = #status#
   </isNotEmpty>
   <isNotEmpty prepend=" AND " property="partnerId">
      oo.PARTNER_ID = #partnerId#
   </isNotEmpty>
   <isNotEmpty prepend=" AND " property="orderSource">
      oo.ORDER_SOURCE = #orderSource#
   </isNotEmpty>
   <isNotEmpty prepend=" AND " property="orderTimeStartDate">
      oo.ORDER_TIME &gt;= #orderTimeStartDate#
   </isNotEmpty>
   <isNotEmpty prepend=" AND " property="orderTimeEndDate">
      oo.ORDER_TIME &lt;= concat(#orderTimeEndDate#,${iplat.time.suffix})
   </isNotEmpty>
   <isNotEmpty prepend=" AND " property="receiver">
      oo.RECEIVER like concat('%',#receiver#,'%')
   </isNotEmpty>
   <isNotEmpty prepend=" AND " property="mobile">
      oo.MOBILE like concat('%',#mobile#,'%')
   </isNotEmpty>
   <isNotEmpty prepend=" AND " property="sqlFilter">
      ($sqlFilter$)
   </isNotEmpty>
   <dynamic prepend="ORDER BY">
        <isNotEmpty property="orderBy">
            $orderBy$
       </isNotEmpty>
      <isEmpty property="orderBy">
          orderColumnTable.orderColumn desc
   </isEmpty>
      </dynamic>

</select>

2.标红的地方需要注意,不然会报错

转载于:https://my.oschina.net/nixi0608/blog/725414

最后

以上就是奋斗人生为你收集整理的ibatis 中传入list对象的全部内容,希望文章能够帮你解决ibatis 中传入list对象所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(52)

评论列表共有 0 条评论

立即
投稿
返回
顶部