Mybatis批量增删改查

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:

你可能感兴趣的:(mybatis)