posts - 41, comments - 15, trackbacks - 0, articles - 1
            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          ibatis批量插入表例子

          Posted on 2012-02-15 14:00 yuhaibo736 閱讀(2017) 評論(0)  編輯  收藏

          public Integer batchInsertEntitylist(final List<Entity> list) {

            return (Integer) this.getSqlMapClientTemplate().execute(new SqlMapClientCallback() {

             public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {

              executor.startBatch();
              int batch = 0;
              int count = 0;
              for (Entity entity: list) {
               executor.insert("insertEntitylist", entity);
               batch++;
               if (batch == 500) {
                executor.executeBatch();
                batch = 0;
               }
              }
              executor.executeBatch();
              count = 1;
              return count;
             }

            });
           }


          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 宁安市| 鲁山县| 德化县| 华宁县| 郧西县| 当涂县| 巴林左旗| 镇康县| 阿克| 巴东县| 工布江达县| 湖南省| 广元市| 象州县| 合山市| 纳雍县| 墨玉县| 澎湖县| 鹤庆县| 资兴市| 博白县| 青岛市| 余江县| 任丘市| 阿瓦提县| 道孚县| 鱼台县| 军事| 平塘县| 尚义县| 无棣县| 扎兰屯市| 遵义县| 长子县| 石河子市| 鲜城| 乌审旗| 淮南市| 安远县| 曲水县| 遵义市|