Posted on 2012-02-15 14:00 
yuhaibo736 阅读(2022) 
评论(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;
   }
  });
 }