码迷,mamicode.com
首页 > 其他好文 > 详细

mybatis 注解写法 多层嵌套foreach,调用存储过程,批量插入数据

时间:2019-05-20 17:23:03      阅读:497      评论:0      收藏:0      [点我收藏+]

标签:end   invoice   state   exec   dex   oid   ali   tis   mybatis   

 1    @Select("<script>" +
 2   "DECLARE @edi_Invoice_Details edi_Invoice_Details;" +
 3   "DECLARE @edi_Invoice_OrderItem edi_Invoice_OrderItem;" +
 4 
 5   "INSERT INTO @edi_Invoice_Details (" +
 6    "oldso,so,po,invoiceTaxNo,invoiceType,invoiceTitle,\n" +
 7    "invoiceAddress,invoiceState,invoiceTaxRate,invoiceContent,\n" +
 8    "invoiceRatePrice,invoiceNoTaxPrice,invoiceId,invoiceDate,invoiceTaxPrice,invoiceNO,invoiceCode" +
 9    " ) " +
10    "VALUES " +
11    "<foreach collection=\"ediInvoiceDetails\" item=\"ediInvoiceDetail\" index=\"index\" separator=\",\" close=\";\">" +
12    "( " +
13      "#{ediInvoiceDetail.oldso},#{ediInvoiceDetail.so},#{ediInvoiceDetail.po},#{ediInvoiceDetail.invoiceTaxNo},#{ediInvoiceDetail.invoiceType},#{ediInvoiceDetail.invoiceTitle}," +
14      "#{ediInvoiceDetail.invoiceAddress},#{ediInvoiceDetail.invoiceState},#{ediInvoiceDetail.invoiceTaxRate},#{ediInvoiceDetail.invoiceContent},#{ediInvoiceDetail.invoiceRatePrice}," +
15      "#{ediInvoiceDetail.invoiceNoTaxPrice},#{ediInvoiceDetail.invoiceId},CONVERT(DATETIME,#{ediInvoiceDetail.invoiceDate},105),#{ediInvoiceDetail.invoiceTaxPrice},"+
16      "#{ediInvoiceDetail.invoiceNO},#{ediInvoiceDetail.invoiceCode}"+
17     " )" +
18      "</foreach> " +
19      "<foreach collection=\"ediInvoiceDetails\" item=\"ediInvoiceDetail\" index=\"index\" open=\"begin\" close=\";end;\" separator=\";\">" +
20      "INSERT INTO @edi_Invoice_OrderItem ( " +
21      "invoiceDetailsId, so, bomCode, agreementPrice,productAmount, productName " +
22      ") " +
23      "VALUES " +
24 
25      "<foreach collection=\"ediInvoiceDetail.sodetails\" item=\"sodetail\" index=\"index\" separator=\",\">( " +
26       "#{sodetail.invoiceDetailsId},#{sodetail.so},#{sodetail.bomCode},#{sodetail.agreementPrice},#{sodetail.productAmount},#{sodetail.productName} "+
27       " )</foreach></foreach> " +
28 
29      "EXEC up_EDI_Sync_SaveEDIInvoiceDetails @edi_Invoice_Details,@edi_Invoice_OrderItem"+
30     "</script>")
31     @Options(statementType = StatementType.CALLABLE)
32     void saveEdiInvoiceDetails(@Param("ediInvoiceDetails") List<EDIInvoiceDetails> ediInvoiceDetails);

 

mybatis 注解写法 多层嵌套foreach,调用存储过程,批量插入数据

标签:end   invoice   state   exec   dex   oid   ali   tis   mybatis   

原文地址:https://www.cnblogs.com/sbk613/p/10894909.html

(1)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!