Mybatis 批量操作

批量添加

1.业务接口

public interface IManService {
    public void addList (List list);
}

2.Mapper接口

public interface IManMapper {
      public void addList (@Param("list")List list);
}

 3.sql语句


     
        insert into t_man(m_name,m_gender,m_birthday,m_tel) values
        
            (#{man.name},#{man.gender},#{man.birthday},#{man.tel})
        
    
<\mapper>
  • 循环标签
  • collection="list" 需要遍历的集合
  • item="man"  循环变量(集合中的元素)
  • separator=","  循环间的

你可能感兴趣的:(#,MyBatis,mybatis,java,数据库)