9oijl1111 发表于 2016-11-29 08:48:54

MyBatis批量插入



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

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




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<insert id="batchInsert" parameterType="LoanRepay" useGeneratedKeys="true">
    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>



页: [1]
查看完整版本: MyBatis批量插入