Mybatis 动态插入 Liste : :
<insert id = "SavePrPcitemkindlist" ParameterType = "java.util.list"> Insérer dans Prpcitemkind (Riskcode, Itemkindno, Familyno, FamilyName, Projectcode, Clausecode StartDate, Starthour, Enddate, Endhour, modèle, achatDate, AddressNo, CalculateFlag, Currency, Unitamount, Quantit, Unit, Value, Montant, Rateperiod, Rate, ShortrateFlag, Shortrate, Prepremium, Calpremium, Basepremium, Benchmarkpremium, Adjustra Inserttimeforhis, operatetimeforhis, taxrate, taxflag, taxfee, netpremium, taxfee_gb, taxfee_lb, allTaxFee, allnetpremium, proposer) <foreach collection = "item =" item "index =" index "séparateur =" Union "> <Trim prefix =" Select "Suffix =" test = "item.RiskCode! = null"> # {item.riskcode}, </ when> <sinon> null, </norel> </ choisi> <moose> <quand test = "item.itemkindno! = null"> # {item.itemkindno}, </ when> <sinon> null, </norel> </isoose> </ Choose> </ Choose> </noose null "> # {item.familyno}, </ when> <sinon> null, </ sinon> </ choix> <poose> <quand test =" item.familyname! = null "> # {item.familyname}, </ when> <sinon> null, </nareil> </pooing> <choix> null "> # {item.projectcode}, </ when> <sinon> null, </ sinon> </ choix> <poose> <quand test =" item.clausecode! = null "> # {item.clausecode}, </ when> <sinon> null, </nareil> </poose> <choix> null "> # {item.clausename}, </ when> <sinon> null, </ sinon> </ choisi> <poose> <quand test =" item.kindcode! = null "> # {item.kindcode}, </ when> <sinon> null, </ sinon> </ Choison null "> # {item.kindname}, </ when> <sinon> null, </ sinon> </ choisi> <moose> <quand test =" item.itemno! = null "> # {item.itemno}, </ when> <sinon> null, </ sinon> </ Choose> <o choix> <quand test =" élément.itemcode! = null "> # {item.itemcode}, </ when> <sinon> null, </ sinon> </ choix> <poose> <quand test =" item.itemdetailName! = null "> # {item.itemdetailName}, </ when> <sinon> null, </nared> </poose> <o choix> null "> # {item.groupno}, </ quand> <sinon> null, </ sinon> </ choisi> <moose> <quand test =" item.modecode! = null "> # {item.modecode}, </ when> <sinon> null, </ sinon> </poisonse> <poose> <quand test =" item.Modename! = null "> # {item.modename}, </ when> <sinon> null, </ sinon> </ choix> <moose> <quand test =" item.startDate! = null "> # {item.startdate}, </ whener> <sinon> null, </ sinon> </poisonse> <poose> <quand test =" item.starthour! = null "> # {item.starthour}, </ when> <sinon> null, </ sinon> </ choix> <moose> <quand test =" item.enddate! = null "> # {item.enddate}, </ when> <sinon> null, </ sinon> </poose> <poose> <quand test =" item.endhour! = null "> # {item.endhour}, </ when> <sinon> null, </ sinon> </ choisi> <moose> <quand test =" item.model! = null "> # {item.model}, </ when> <sinon> null, </ sinon> </ Choose> </ Choice> <quand test =" item.buydate! = null "> # {item.buydate}, </ when> <sinon> null, </ sinon> </ choisi> <poose> <quand test =" item.addressno! = null "> # {item.addressno}, </ when> <sinon> null, </ sinon> </poose> <o choix> <quand test =" item.calculateflag! = null "> # {item.calculateflag}, </ when> <sinon> null, </ sinon> </ choisi> <poose> <quand test =" item.currency! = null "> # {item.currency}, </ when> <sinon> null, </ sinon> </poose> <poose> <quand test =" élément.unitamount! = null "> # {item.unitamount}, </ quand> <sinon> null, </ sinon> </ choisi> <moose> <quand test =" item.quantity! = null "> # {item.quantity}, </ when> <sinon> null, </ sinon> </ Choose> <o choix> <quand test =" élément.unit! = null "> # {item.unit}, </ when> <sinon> null, </ sinon> </ choisi> <moose> <quand tester =" item.value! = null "> # {item.value}, </ when> <sinon> null, </ sinon> </ choisi> </ choix> <quand test =" item.amount! = null "> # {item.amount}, </ when> <sinon> null, </ sinon> </ choisi> <moose> <quand tester =" item.Rateperiod! = null "> # {item.rateperiod}, </ when> <sinon> null, </ sinon> </ Choose> <o choix> <quand test =" item.rate! = null "> # {item.rate}, </ when> <sinon> null, </ sinon> </ choix> <poose> <quand tester =" item.shortrateflag! = null "> # {item.shortrateflag}, </ when> <sinon> null, </ sinon> </poisonse> <o choix> <quand test =" item.shortrate! = null "> # {item.shortrate}, </ when> <sinon> null, </ sinon> </ choix> <moose> <quand test =" item.prepremium! = null "> # {item.prepremium}, </ when> <sinon> null, </ autrement> </poisonse> </ où test =" item.calpreme! = null "> # {item.calpremium}, </ when> <sinon> null, </ sinon> </ choisi> <poose> <quand test =" item.basepremium! = null "> # {item.basepremium}, </ when> <sinon> null, </nareil> </poose> <choix> null "> # {item.benchmarkPremium}, </ when> <sinon> null, </ sinon> </ choisi> <poose> <quand test =" item.discount! = null "> # {item.discount}, </ when> <sinon> null, </ sinon> </poisonse> <poose> <quand test =" élément.adjustr! = null "> # {item.adjustrate}, </ when> <sinon> null, </ sinon> </ choix> <moose> <quand test =" item.unitpremium! = null "> # {item.unitpremium}, </ when> <sinon> null, </ sinon> </ Choose> <o choix> <quand test =" item.premium! = null "> # {item.premium}, </ when> <sinon> null, </ sinon> </ choisi> </ choix> <quand test =" item.dedudublerate! = null "> # {item.deduductiblerate}, </wors> <sinon> null, </nareil> </poose> <poire> <quand test =" item.Deduble! = null "> # {item.deductible}, </ when> <sinon> null, </ sinon> </ choisi> <moose> <quand test =" item.flag! = null "> # {item.flag}, </ when> <sinon> null, </ sinon> </ choisi> </ choix> <quand test =" item.insertTimeforHis! = null "> # {item.inserttimeforhis}, </ when> <sinon> null, </ sinon> </ choix> <poose> <quand test =" item.operatetimeforhis! = null "> # {item.operatetimeforhis}, </ when> <sinon> null, </notel> </poose> </ choix> <quand test =" item.Taxrate! = null "> # {item.taxrate}, </ when> <sinon> null, </ sinon> </ choisi> <moose> <quand test =" item.taxflag! = null "> # {item.taxflag}, </ when> <sinon> null, </ sinon> </poose> <poose> <quand test =" élément.taxfee! = null "> # {item.taxfee}, </ when> <sinon> null, </ sinon> </ choix> <moose> <quand test =" item.netpremium! = null "> # {item.netpremium}, </ when> <sinon> null, </ sinon> </poose> <oplic> <quand test =" item.taxfee_gb! = null "> # {item.taxfee_gb}, </ when> <sinon> null, </ sinon> </ choisi> <poose> <quand test =" item.taxfee_lb! = null "> # {item.taxfee_lb}, </ when> <sinon> null, </ sinon> </isoose> <o choix> <Quand test =" null "> # {item.alltaxfee}, </ when> <sinon> null, </ sinon> </ choisi> <poose> <quand test =" item.allnetpremium! = null "> # {item.allnetpremium}, </ when> <sinon> null, </ sinon> </ Choose> # {item.proposalno} </ trim> </ pour laach>Mybatis 传入 Liste : :
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 où p.id dans <forfeach élément = "item" 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 = purDeliveryPandao .getPlanListManual (INID); // dao 层代码 list <map <string, string >> getPlanListManual (@param ("INID") String INID); // xml 文件 <select id = "getPlanListmanual" ParameterType = "java.lang.string" resultType = "java.util.map"> sélectionner p.supplier_code, p.pur_order_no, if (p.update_times> 0, '修改订单', '新订单') As Order_Type p.is_notice = '0' et p.is_delete = '1' et p.id dans (<! [cdata [$ {INID}]]>) Groupe par p.supplier_code, p.pur_order_no ordre par p.supplier_code </ select>总结
以上所述是小编给大家介绍的 Mybatis 动态插入 Liste 传入 Liste 参数的实例代码 , 希望对大家有所帮助 , 如果大家有任何疑问欢迎给我留言 , 小编会及时回复大家的!