欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

mybatis動態(tài)插入list傳入List參數的實例代碼

 更新時間:2018年04月21日 13:43:27   投稿:mrr  
本文通過實例代碼給大家介紹了mybatis動態(tài)插入list,Mybatis 傳入List參數的方法,非常不錯,具有參考借鑒價值,需要的朋友參考下吧

mybatis動態(tài)插入list的實例代碼如下所述:

<insert id="savePrpcitemkindList" parameterType="java.util.List">
insert into prpcitemkind
(RISKCODE, ITEMKINDNO, FAMILYNO, FAMILYNAME, PROJECTCODE, CLAUSECODE,
CLAUSENAME,
KINDCODE, KINDNAME, ITEMNO, ITEMCODE, ITEMDETAILNAME, GROUPNO, MODECODE,
MODENAME, STARTDATE,
STARTHOUR, ENDDATE, ENDHOUR, MODEL, BUYDATE, ADDRESSNO, CALCULATEFLAG, CURRENCY,
UNITAMOUNT,
QUANTITY, UNIT, VALUE, AMOUNT, RATEPERIOD, RATE, SHORTRATEFLAG, SHORTRATE,
PREPREMIUM, CALPREMIUM,
BASEPREMIUM, BENCHMARKPREMIUM, DISCOUNT, ADJUSTRATE, UNITPREMIUM, PREMIUM,
DEDUCTIBLERATE, DEDUCTIBLE,
FLAG, INSERTTIMEFORHIS, OPERATETIMEFORHIS, TAXRATE, TAXFLAG, TAXFEE,
NETPREMIUM, TAXFEE_GB, TAXFEE_LB, ALLTAXFEE, ALLNETPREMIUM,PROPOSALNO)
<foreach collection="list" item="item" index="index" separator="union all">
<trim prefix="select" suffix="from dual">
<choose>
<when test="item.riskcode != null">#{item.riskcode},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.itemkindno != null">#{item.itemkindno},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.familyno != null">#{item.familyno},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.familyname != null">#{item.familyname},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.projectcode != null">#{item.projectcode},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.clausecode != null">#{item.clausecode},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.clausename != null">#{item.clausename},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.kindcode != null">#{item.kindcode},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.kindname != null">#{item.kindname},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.itemno != null">#{item.itemno},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.itemcode != null">#{item.itemcode},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.itemdetailname != null">#{item.itemdetailname},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.groupno != null">#{item.groupno},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.modecode != null">#{item.modecode},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.modename != null">#{item.modename},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.startdate != null">#{item.startdate},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.starthour != null">#{item.starthour},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.enddate != null">#{item.enddate},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.endhour != null">#{item.endhour},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.model != null">#{item.model},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.buydate != null">#{item.buydate},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.addressno != null">#{item.addressno},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.calculateflag != null">#{item.calculateflag},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.currency != null">#{item.currency},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.unitamount != null">#{item.unitamount},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.quantity != null">#{item.quantity},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.unit != null">#{item.unit},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.value != null">#{item.value},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.amount != null">#{item.amount},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.rateperiod != null">#{item.rateperiod},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.rate != null">#{item.rate},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.shortrateflag != null">#{item.shortrateflag},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.shortrate != null">#{item.shortrate},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.prepremium != null">#{item.prepremium},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.calpremium != null">#{item.calpremium},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.basepremium != null">#{item.basepremium},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.benchmarkpremium != null">#{item.benchmarkpremium},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.discount != null">#{item.discount},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.adjustrate != null">#{item.adjustrate},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.unitpremium != null">#{item.unitpremium},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.premium != null">#{item.premium},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.deductiblerate != null">#{item.deductiblerate},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.deductible != null">#{item.deductible},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.flag != null">#{item.flag},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.inserttimeforhis != null">#{item.inserttimeforhis},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.operatetimeforhis != null">#{item.operatetimeforhis},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.taxrate != null">#{item.taxrate},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.taxflag != null">#{item.taxflag},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.taxfee != null">#{item.taxfee},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.netpremium != null">#{item.netpremium},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.taxfee_gb != null">#{item.taxfee_gb},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.taxfee_lb != null">#{item.taxfee_lb},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.alltaxfee != null">#{item.alltaxfee},</when>
<otherwise>null,</otherwise>
</choose>
<choose>
<when test="item.allnetpremium != null">#{item.allnetpremium},</when>
<otherwise>null,</otherwise>
</choose>
#{item.proposalno}
</trim>
</foreach> 
 </insert>

Mybatis 傳入List參數的實例代碼如下所述:

Java代碼

//dao 代碼 如果傳入的參數是數組,也一樣 
void insertDefaultMsg(@Param("idsList") ArrayList<String> idsList); 
//xml文件 
<update id="insertDefaultMsg" parameterType="java.util.List"> 
    UPDATE  
     plf_pur_delivery_plan p  
    SET 
     p.promise_delivery_amount = p.quantity_req, 
     p.promise_delivery_time = p.quantity_time  
    WHERE p.id IN 
    <foreach item="item" collection="idsList" separator="," open="(" close=")" index="">  
     #{item, jdbcType=VARCHAR}  
    </foreach>  
  </update> 
//如果傳入字符串 
//service 代碼 
Map<String, String> map = bean.getDatas().get(0); 
    String ids = map.get("ids"); 
    String[] idsArr = ids.split(","); 
    String inId = ""; 
    for (int i = 0; i < idsArr.length; i++) { 
      if (i != idsArr.length - 1) { 
        inId += "'" + idsArr[i] + "',"; 
      } else { 
        inId += "'" + idsArr[i] + "'"; 
      } 
    } 
    List<Map<String, String>> list = purDeliveryPlanDao 
        .getPlanListManual(inId); 
//dao層代碼 
List<Map<String, String>> getPlanListManual(@Param("inId") String inId); 
//xml 文件 
<select id="getPlanListManual" parameterType="java.lang.String" resultType="java.util.Map"> 
    SELECT  
     p.supplier_code, 
     p.pur_order_no, 
     IF( 
      p.update_times > 0, 
      '修改訂單', 
      '新訂單' 
     ) AS order_type  
    FROM 
     plf_pur_delivery_plan p  
    WHERE p.is_notice = '0'  
     AND p.is_delete = '1'  
     AND p.id in(<![CDATA[${inId}]]>) 
    GROUP BY p.supplier_code, 
     p.pur_order_no  
    ORDER BY p.supplier_code  
  </select> 

總結

以上所述是小編給大家介紹的mybatis動態(tài)插入list傳入List參數的實例代碼,希望對大家有所幫助,如果大家有任何疑問歡迎給我留言,小編會及時回復大家的!

相關文章

  • java編程創(chuàng)建型設計模式工廠方法模式示例詳解

    java編程創(chuàng)建型設計模式工廠方法模式示例詳解

    這篇文章主要為大家介紹了java編程創(chuàng)建型設計模式之工廠方法模式的創(chuàng)建及案例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助
    2022-02-02
  • Springboot中使用Redis實現(xiàn)分布式鎖的示例代碼

    Springboot中使用Redis實現(xiàn)分布式鎖的示例代碼

    在分布式系統(tǒng)中,為了保證數據的一致性和任務的互斥執(zhí)行,分布式鎖是一種常見的解決方案,本文主要介紹了Springboot中使用Redis實現(xiàn)分布式鎖的示例代碼,具有一定的參考價值,感興趣的可以了解一下
    2024-05-05
  • JavaWeb使用mvc模式實現(xiàn)登錄功能

    JavaWeb使用mvc模式實現(xiàn)登錄功能

    本文主要介紹了JavaWeb使用mvc模式實現(xiàn)登錄功能,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-01-01
  • Java無限級樹(遞歸)超實用案例

    Java無限級樹(遞歸)超實用案例

    下面小編就為大家?guī)硪黄狫ava無限級樹(遞歸)超實用案例。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2016-11-11
  • 線程池之jdk1.8 Executors創(chuàng)建線程池的幾種方式

    線程池之jdk1.8 Executors創(chuàng)建線程池的幾種方式

    這篇文章主要介紹了線程池之jdk1.8 Executors創(chuàng)建線程池的幾種方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-08-08
  • Java中Collection和Collections的區(qū)別

    Java中Collection和Collections的區(qū)別

    Collection是一個集合接口,集合類的頂級接口,Collections是一個包裝類,本文主要介紹了Java中Collection和Collections的區(qū)別,具有一定的參考價值,感興趣的可以了解一下
    2024-04-04
  • ThreadLocal?在上下文傳值場景實踐源碼

    ThreadLocal?在上下文傳值場景實踐源碼

    這篇文章主要為大家介紹了ThreadLocal在上下文傳值場景下的實踐源碼,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步
    2022-03-03
  • Java中checkbox實現(xiàn)跨頁多選的方法

    Java中checkbox實現(xiàn)跨頁多選的方法

    最近做了一個項目其中遇到這樣的需求,要實現(xiàn)checkbox跨頁多選功能,經過小編整理,順利解決,今天小編給大家分享Java中checkbox實現(xiàn)跨頁多選的方法,需要的的朋友參考下
    2017-01-01
  • Mybatis CURD及模糊查詢功能的實現(xiàn)

    Mybatis CURD及模糊查詢功能的實現(xiàn)

    這篇文章主要介紹了Mybatis CURD及模糊查詢功能的實現(xiàn),有查詢刪除,插入,更新功能,通過實例代碼講解的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2021-06-06
  • RocketMQ整合SpringBoot實現(xiàn)生產級二次封裝

    RocketMQ整合SpringBoot實現(xiàn)生產級二次封裝

    本文主要介紹了RocketMQ整合SpringBoot實現(xiàn)生產級二次封裝,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2022-06-06

最新評論