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

          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;
             }

            });
           }


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


          網站導航:
           
          主站蜘蛛池模板: 龙州县| 宕昌县| 万源市| 泸定县| 独山县| 永安市| 安宁市| 北宁市| 平利县| 天镇县| 增城市| 潞西市| 任丘市| 巢湖市| 集贤县| 镇江市| 长治县| 博野县| 赞皇县| 红河县| 花垣县| 宿松县| 石家庄市| 抚宁县| 双柏县| 兴国县| 临猗县| 宜宾县| 舒城县| 中西区| 桂林市| 铜山县| 洱源县| 建平县| 汉中市| 安义县| 禹州市| 扎囊县| 成安县| 乌兰浩特市| 湖北省|