Mybatis批量增删改查
•
Jave
1.批量新增
mapper层:
Integer batchAdd(@Param("list")List userEntity);
xml:
INSERT INTO 表名(name, age, gender, psw, seq) values
( #{item.name},#{item.age},#{item.gender},#{item.psw},#{item.seq})
2.批量删除
mapper层:
Integer batchDelete(@Param("idList") List idList);
xml:
DELETE FROM 表名 where id in
#{item}
3.批量更新
mapper层:
Integer batchUpdateOneVariable(@Param("user") UserEntity user,@Param("idList") List idList);
xml:
UPDATE 表名 set psw=#{user.psw}
id in (
#{item}
)
4.批量查询
mapper层:
List batchSelect2(UserEntity2 userEntity2);
xml:
select * from 表名
id in
#{item}
本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://www.net2asp.com/d86e181813.html
