NutzCN Logo
问答 dao.insert(tableName,Chain) 支持批量插入吗
发布于 2544天前 作者 hzl7652 2281 次浏览 复制 上一个帖子 下一个帖子
标签:
dao.insert("t_pet", Chain.make("name","XiaoBai").add("birthday", new Timestampe(System.currentTimeMillis())));

dao.insert(tableName,Chain) 如何加速insert 速度

2 回复
    @Test
    public void test_fast_insert_maps() {
        List<NutMap> list = new ArrayList<NutMap>();
        for (int i = 0; i < 100; i++) {
            NutMap pet = new NutMap();
            pet.setv("name", "wendal" + i).setv("age", i);
            list.add(pet);
        }
        // 为第一条记录设置表名称
        list.get(0).setv(".table", "t_pet");
        
        dao.fastInsert(list);
    }

输出

2017-05-31 13:44:44,734 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - INSERT INTO t_pet(name,age) VALUES(?,?) 
    |        1 |  2 |
    |----------|----|
    | wendal0  | 0  |
    | wendal1  | 1  |
    | wendal2  | 2  |
    | wendal3  | 3  |
    | wendal4  | 4  |
    | wendal5  | 5  |
    | wendal6  | 6  |
    | wendal7  | 7  |
    | wendal8  | 8  |
    | wendal9  | 9  |
 -- Only display first 10 lines , don't show the remaining record(count=100)
  For example:> "INSERT INTO t_pet(name,age) VALUES('wendal0',0) "

添加回复
请先登陆
回到顶部