曾在學習redis時,技術牛畫了乙個資料庫的發展圖,redis最終發展竟是關係型資料庫;你恨不得想說個oh ,****!就像ibatis發展到mybatis,最後發展方向極可能是hibernate,這個...
create table batch_options_test
( id varchar2(50) not null,
name varchar2(50)
)
public class batchoptiontest
int batchinserttestmethod(@param(value="list")listdatalist);
} 1:mybatis 批量新增
(1)批量新增方式1
insert into batch_insert_test (id,name) values('1','smartisan t1');
insert into batch_insert_test (id,name) values('2','堅果');
0">insert into batch_options_test(id,name) values (#,#)
測試新增資料成功,返回值是-1(關於返回值,可以參考oracle doc 的解釋,因為我也沒弄清楚,哈哈)。
(2)批量新增方式2
insert into batch_insert_test(id,name)
select '1','smartisan t1' from dual
union all
select '2','堅果' from dual
0">insert into batch_options_test(id,name)
select (#,#) from dual
測試新增資料成功,返回值等於list的大小。
(3) 總結
批量新增第二種方式更好,也可以根據實際需求,批次批量新增。
2:mybatis 批量更新
int batchupdatetestmethodone(@param(value="list")listdatalist,@param(value="name")string name);
int batchupdatetestmethodtwo(@param(value="list")listdatalist);}
(1)批量更新方式1 (比如將id是1和2的資料name修改為smartisan t2)
0">update batch_options_test
name = #
id in
#
測試更新資料成功,返回值是list的size大小。
(2)批量更新方式2(比如將id是1的資料name修改為smartisan t2,id是2的資料name修改為堅果mini)
0">update batch_options_test
name = #
id=#
測試更新資料成功,返回值是-1(關於返回值,可以參考oracle doc 的解釋,因為我也沒弄清楚,哈哈)。
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 mvc mybatis的配置,使用mybatis批量插入。主要是用foreach標籤,它可以在sql語句中進行迭代乙個集合。foreach元素的屬性主要有 item,index,collection,...
MyBatis 批量插入
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...