MyBatis 批量插入

2021-09-25 22:02:26 字數 844 閱讀 2172

1.遇到問題

insert at least 1 column 報錯說 至少插入一列

錯誤的語句:

select (studentcode,roomcode,n_x,n_y)from
把括號去掉->select studentcode,roomcode,n_x,n_y from

2.column count doesn't match value count at row 1

insert 的值 和 value  個數  不匹配

3.批量不重複插入 原始碼

insert into _record

(pkid,orgid)

select * from (

select

# as_pkid,# as_orgid

from dual

)awhere not exists (select pkid,orgid from _record b where b.pkid= a.as_pkid and b.orgid= a.as_orgid )

5. select  #(中間的空格不要忘記了) as_pkid  

批量插入從昨天下午開始研究,看了很多人的部落格,大部分寫的亂七八糟的 根本不可用,個人感覺寫後台的人很多,但是高手貌似很少

參考部落格:

我的** 是根據這個人部落格裡面的原始碼 實現的,照葫蘆畫瓢!

俠肝義膽沈劍心 : 下山一年 什麼也沒得到,如果沒有出去,說不定已經是純陽七子。

mybatis 批量插入

單字段的批量更新如 list存的只有id 將前端接收的id集合拼接的字串解析 listidlist new arraylist idlist.add 1 idlist.add 2 idlist.add 3 要修改的資訊 sql語句類似 update role set modifier modify ...

mybatis批量插入,批量更新

insert into t ingco trade lithium electric product product no,li e product no,transpor report number,msds,transpor report number path,msds path,un tes...

MyBatis批量插入資料

在程式中封裝了乙個list集合物件,然後需要把該集合中的實體插入到資料庫中,由於專案使用了spring mybatis的配置,所以打算使用mybatis批量插入,由於之前沒用過批量插入,在網上找了一些資料後最終實現了,把詳細過程貼出來 實體類trainrecord結構如下 public class ...