问题描述
- 参数list对象结果如何使用mybatis批量插入数据
-
使用mybatis oracle,当传来的参数是list对象结果集,如何批量插入数据
解决方案
解决方案二:
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<!--
表的序列查询
-->
select TABLE_SEQ.NEXTVAL from DUAL
</selectKey>
insert into TABLE
( ID,
NAME,
PASSWORD,
AGE,
CREATETIME)
select tableseq.NEXTVAL,a.* from (
<foreach collection="list" item="item" index="index"
separator="union all">
select
#{item.name,jdbcType=VARCHAR} as name,
#{item.password,jdbcType=VARCHAR} as password,#{item.age,jdbcType=BECIMAL} as age,#{item.createTime,jdbcType=TIMESTAMP} as createTime
from dual
</foreach>
) a
解决方案三:
INSERT ALL
into TRX_BILL_DETAIL_INFO
ID,
CUST_NO,
TRANS_CODE,
TRANS_REFNO,
TRANS_SEQNO,
ORDER_NO,
TRANS_AMT,
BILL_DATE,
BILL_FLAG,
TRANS_DESC,
#{item.id,jdbcType=DECIMAL},
#{item.custNo,jdbcType=CHAR},
#{item.transCode,jdbcType=CHAR},
#{item.transRefno,jdbcType=CHAR},
#{item.transSeqno,jdbcType=VARCHAR},
#{item.orderNo,jdbcType=CHAR},
#{item.transAmt,jdbcType=DECIMAL},
#{item.billDate,jdbcType=DECIMAL},
#{item.billFlag,jdbcType=CHAR},
#{item.transDesc,jdbcType=VARCHAR},
select 1 from dual
时间: 2024-11-02 16:43:40