首页 > 代码库 > MyBatis批量插入

MyBatis批量插入

List<LoanRepay>  = ;
loanRepayDAO.batchInsert(allLoanRepayList);

batchInsert(List<LoanRepay> loanRepayList){
    getSqlSession().insert(++,loanRepayList);
}

<insert id="batchInsert" parameterType="LoanRepay" useGeneratedKeys="true" keyProperty="id">
    insert into loan_repay(
    loano,
    mercno,
    mgrno,
    custno,
    idx,
    paydate,
    tc,
    pay,
    rptime,
    state,
    vn,
    crtime,
    uptime
    ) values
    <foreach collection="list" item="item" index="index" separator="," >
    (
    #{item.loano},
    #{item.mercno},
    #{item.mgrno},
    #{item.custno},
    #{item.idx},
    #{item.paydate},
    #{item.tc},
    #{item.pay},
    #{item.rptime},
    #{item.state},
    1,
    current_timestamp,
    current_timestamp
    )
    </foreach>
</insert>


本文出自 “熔 岩” 博客,请务必保留此出处http://lavasoft.blog.51cto.com/62575/1877413

MyBatis批量插入