zoukankan      html  css  js  c++  java
  • Mybatis批量插入数据

    Controller层:

    Student stu=new Student();
    stu.SetName("小三");
    stu.SetAge(12);
    stu.SetSex("男");
    Student stu2=new Student();
    stu.SetName("小四");
    stu.SetAge(13);
    stu.SetSex("男");
    Student stu3=new Student();
    stu.SetName("小五");
    stu.SetAge(14);
    stu.SetSex("女");
    List list =new ArrayList();
    list.add(stu);
    list.add(stu2);
    list.add(stu3);
    StudentService.insert(list);

    xml层:

    <insert id="insertStu" parameterType="java.util.List">
            insert into
            tb_student
             (name,sex,age)
            VALUES
            <foreach collection="list" item="item" index= "index" separator =",">
                (#{item.name}, #{item.sex},#{item.age})
            </foreach>
        </insert>
  • 相关阅读:
    tcp socket http(复制的)
    cas php
    占用字节
    网络基础
    Mbps MB/S Mb/s
    path_info和get_full_path()的区别
    rbac权限管理
    ORM _meta
    Django SQLite3的使用
    url的分发
  • 原文地址:https://www.cnblogs.com/SmallStrange/p/12982611.html
Copyright © 2011-2022 走看看