mybatis动态插入list传入List参数的实例代码

网友投稿 327 2023-02-08


mybatis动态插入list传入List参数的实例代码

mybatis动态插入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)

#{item.riskcode},

null,

#{item.itemkindno},

null,

#{item.familyno},

null,

#{item.familyname},

null,

#{item.projectcode},

null,

#{item.clausecode},

null,

#{item.clausename},

null,

#{item.kindcode},

null,

#{item.kindname},

null,

#{item.itemno},

null,

#{item.itemcode},

null,

#{item.itemdetailname},

null,

#{item.groupno},

null,

#{item.modecode},

null,

#{item.modename},

null,

#{item.startdate},

null,

#{item.starthour},

null,

#{item.enddate},

null,

#{item.endhour},

null,

#{item.model},

null,

#{item.buydate},

null,

#{item.addressno},

null,

#{item.calculateflag},

null,

#{item.currency},

null,

#{item.unitamount},

null,

#{item.quantity},

null,

#{item.unit},

null,

#{item.value},

null,

#{item.amount},

null,

#{item.rateperiod},

null,

#{item.rate},

null,

#{item.shortrateflag},

null,

#{item.shortrate},

null,

#{item.prepremium},

null,

#{item.calpremium},

null,

#{item.basepremium},

null,

#{item.benchmarkpremium},

null,

#{item.discount},

null,

#{item.adjustrate},

null,

#{item.unitpremium},

null,

#{item.premium},

null,

#{item.deductiblerate},

null,

#{item.deductible},

null,

#{item.flag},

null,

#{item.inserttimeforhis},

null,

#{item.operatetimeforhis},

null,

#{item.taxrate},

null,

#{item.taxflag},

null,

#{item.taxfee},

null,

#{item.netpremium},

null,

#{item.taxfee_gb},

null,

#{item.taxfee_lb},

null,

#{item.alltaxfee},

null,

#{item.allnetpremium},

null,

#{item.proposalno}

Mybatis 传入List参数的实例代码如下所述:

Java代码

//dao 代码 如果传入的参数是数组,也一样

void insertDefaultMsg(@Param("idsList") ArrayList idsList);

//xml文件

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

#{item, jdbcType=VARCHAR}

//如果传入字符串

//service 代码

Map 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> list = purDeliveryPlanDao

.getPlanListManual(inId);

//dao层代码

List> getPlanListManual(@Param("inId") String inId);

//xml 文件

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

总结

以上所述是给大家介绍的mybatis动态插入list传入List参数的实例代码,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,会及时回复大家的!


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:vue源码解析之事件机制原理
下一篇:数字货币API接口管理(数字货币对接系统)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~