当前位置: 首页>>代码示例>>Java>>正文


Java BatchPreparedStatementSetter类代码示例

本文整理汇总了Java中org.springframework.jdbc.core.BatchPreparedStatementSetter的典型用法代码示例。如果您正苦于以下问题:Java BatchPreparedStatementSetter类的具体用法?Java BatchPreparedStatementSetter怎么用?Java BatchPreparedStatementSetter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BatchPreparedStatementSetter类属于org.springframework.jdbc.core包,在下文中一共展示了BatchPreparedStatementSetter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: save

import org.springframework.jdbc.core.BatchPreparedStatementSetter; //导入依赖的package包/类
@Override
public void save(String graphName, String version, List<IDefaultSegmentXInfo> xInfoList) throws GraphNotExistsException {
	if (xInfoList != null) {
		preProcessList(graphName, version, xInfoList);
		getJdbcTemplate().batchUpdate("INSERT INTO " + schema + TABLENAME + " (segment_id, direction_tow, graphversion_id, tags) VALUES (?,?,?,?)",
				new BatchPreparedStatementSetter() {
					
					@Override
					public void setValues(PreparedStatement ps, int i) throws SQLException {
						ps.setLong(1, xInfoList.get(i).getSegmentId());
						if (xInfoList.get(i).isDirectionTow() != null) {
							ps.setBoolean(2, xInfoList.get(i).isDirectionTow());
						} else {
							ps.setNull(2, Types.BOOLEAN);
						}
						ps.setLong(3, xInfoList.get(i).getGraphVersionId());
						ps.setObject(4, xInfoList.get(i).getValues());
					}
					
					@Override
					public int getBatchSize() {
						return xInfoList.size();
					}
				});
	}
}
 
开发者ID:graphium-project,项目名称:graphium,代码行数:27,代码来源:DefaultSegmentXInfoDaoImpl.java

示例2: update

import org.springframework.jdbc.core.BatchPreparedStatementSetter; //导入依赖的package包/类
@Override
public void update(String graphName, String version, List<IDefaultSegmentXInfo> xInfoList) throws GraphNotExistsException {
	if (xInfoList != null) {
		preProcessList(graphName, version, xInfoList);
		getJdbcTemplate().batchUpdate("UPDATE " + schema + TABLENAME + " SET tags=? WHERE segment_id=? AND direction_tow=? AND graphversion_id=?",
				new BatchPreparedStatementSetter() {
					
					@Override
					public void setValues(PreparedStatement ps, int i) throws SQLException {
						ps.setObject(1, xInfoList.get(i).getValues());
						ps.setLong(2, xInfoList.get(i).getSegmentId());
						ps.setBoolean(3, xInfoList.get(i).isDirectionTow());
						ps.setLong(4, xInfoList.get(i).getGraphVersionId());
					}
					
					@Override
					public int getBatchSize() {
						return xInfoList.size();
					}
				});
	}
}
 
开发者ID:graphium-project,项目名称:graphium,代码行数:23,代码来源:DefaultSegmentXInfoDaoImpl.java

示例3: swapIdUsingDataFromFile

import org.springframework.jdbc.core.BatchPreparedStatementSetter; //导入依赖的package包/类
public void swapIdUsingDataFromFile(String idsFile) throws IOException {
    System.out.println("\nReading ids\n");
    final List<Ids> ids = parseFileForId(idsFile);
    String sql = "UPDATE kaltura_item SET kalturaId = ? where kalturaId = ?";
    System.out.println("Begining database update\n");
    jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
        public int getBatchSize() {
            return ids.size();
        }

        public void setValues(PreparedStatement ps, int index) throws SQLException {
            Ids id = ids.get(index);
            ps.setString(1, id.getNewId());
            ps.setString(2, id.getOldId());
        }
    });
    System.out.println("Update complete\n");
}
 
开发者ID:ITYug,项目名称:kaltura-ce-sakai-extension,代码行数:19,代码来源:JDBCSwitcher.java

示例4: executeBatchUpdateWithNamedParameters

import org.springframework.jdbc.core.BatchPreparedStatementSetter; //导入依赖的package包/类
public static int[] executeBatchUpdateWithNamedParameters(final ParsedSql parsedSql,
		final SqlParameterSource[] batchArgs, JdbcOperations jdbcOperations) {
	if (batchArgs.length <= 0) {
		return new int[] {0};
	}
	String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, batchArgs[0]);
	return jdbcOperations.batchUpdate(
			sqlToUse,
			new BatchPreparedStatementSetter() {

				@Override
				public void setValues(PreparedStatement ps, int i) throws SQLException {
					Object[] values = NamedParameterUtils.buildValueArray(parsedSql, batchArgs[i], null);
					int[] columnTypes = NamedParameterUtils.buildSqlTypeArray(parsedSql, batchArgs[i]);
					setStatementParameters(values, ps, columnTypes);
				}

				@Override
				public int getBatchSize() {
					return batchArgs.length;
				}
			});
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:NamedParameterBatchUpdateUtils.java

示例5: executeBatchInternal

import org.springframework.jdbc.core.BatchPreparedStatementSetter; //导入依赖的package包/类
/**
 * Method to execute the batch insert.
 */
private int[] executeBatchInternal(final List<Object>[] batchValues) {
	if (logger.isDebugEnabled()) {
		logger.debug("Executing statement " + getInsertString() + " with batch of size: " + batchValues.length);
	}
	return getJdbcTemplate().batchUpdate(getInsertString(),
			new BatchPreparedStatementSetter() {
				@Override
				public void setValues(PreparedStatement ps, int i) throws SQLException {
					List<Object> values = batchValues[i];
					setParameterValues(ps, values, getInsertTypes());
				}
				@Override
				public int getBatchSize() {
					return batchValues.length;
				}
			});
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:AbstractJdbcInsert.java

示例6: createEntries

import org.springframework.jdbc.core.BatchPreparedStatementSetter; //导入依赖的package包/类
/**
   * Creates a new row in acl_entry for every ACE defined in the passed MutableAcl object.
   *
   * @param acl containing the ACEs to insert
   */
  protected void createEntries(final MutableAcl acl) {
if (acl.getEntries().isEmpty()) {
	return;
}
      jdbcTemplate.batchUpdate(insertEntry,
      	new BatchPreparedStatementSetter() {
              public int getBatchSize() {
                  return acl.getEntries().size();
              }

              public void setValues(PreparedStatement stmt, int i) throws SQLException {
                  AccessControlEntry entry_ = acl.getEntries().get(i);
                  Assert.isTrue(entry_ instanceof AccessControlEntryImpl, "Unknown ACE class");
                  AccessControlEntryImpl entry = (AccessControlEntryImpl) entry_;
                  stmt.setLong(1, ((Long) acl.getId()).longValue());
                  stmt.setInt(2, i);
                  stmt.setLong(3, createOrRetrieveSidPrimaryKey(entry.getSid(), true).longValue());
                  stmt.setInt(4, entry.getPermission().getMask());
                  stmt.setBoolean(5, entry.isGranting());
                  stmt.setBoolean(6, entry.isAuditSuccess());
                  stmt.setBoolean(7, entry.isAuditFailure());
              }
          });
  }
 
开发者ID:GovernIB,项目名称:helium,代码行数:30,代码来源:JdbcMutableAclService.java

示例7: updateZonePalstaList

import org.springframework.jdbc.core.BatchPreparedStatementSetter; //导入依赖的package包/类
public void updateZonePalstaList(final long zoneId, final int[] boundaryIds) {
    final String insertSql = "INSERT INTO zone_palsta (zone_id, palsta_id, geom, palsta_tunnus)" +
            " SELECT ?, pa.id, pa.geom, pa.tunnus FROM palstaalue pa WHERE pa.id = ?";

    jdbcOperations.batchUpdate(insertSql, new BatchPreparedStatementSetter() {
        @Override
        public void setValues(final PreparedStatement ps, final int i) throws SQLException {
            final Integer palstaId = boundaryIds[i];

            ps.setLong(1, zoneId);
            ps.setInt(2, palstaId);
        }

        @Override
        public int getBatchSize() {
            return boundaryIds.length;
        }
    });
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:20,代码来源:UpdatePalstaFeatureQueries.java

示例8: removeZonePalsta

import org.springframework.jdbc.core.BatchPreparedStatementSetter; //导入依赖的package包/类
public void removeZonePalsta(final long zoneId, final int[] toRemoveArray) {
    final String deleteSql = "DELETE FROM zone_palsta WHERE zone_id = ? AND palsta_id = ?";

    jdbcOperations.batchUpdate(deleteSql, new BatchPreparedStatementSetter() {
        @Override
        public void setValues(final PreparedStatement ps, final int i) throws SQLException {
            ps.setLong(1, zoneId);
            ps.setInt(2, toRemoveArray[i]);
        }

        @Override
        public int getBatchSize() {
            return toRemoveArray.length;
        }
    });
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:17,代码来源:UpdatePalstaFeatureQueries.java

示例9: executeBatchInternal

import org.springframework.jdbc.core.BatchPreparedStatementSetter; //导入依赖的package包/类
/**
 * Delegate method to execute the batch insert.
 */
private int[] executeBatchInternal(final List<List<Object>> batchValues) {
	if (logger.isDebugEnabled()) {
		logger.debug("Executing statement " + getInsertString() + " with batch of size: " + batchValues.size());
	}
	return getJdbcTemplate().batchUpdate(getInsertString(),
			new BatchPreparedStatementSetter() {
				@Override
				public void setValues(PreparedStatement ps, int i) throws SQLException {
					setParameterValues(ps, batchValues.get(i), getInsertTypes());
				}
				@Override
				public int getBatchSize() {
					return batchValues.size();
				}
			});
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:AbstractJdbcInsert.java

示例10: batchSave

import org.springframework.jdbc.core.BatchPreparedStatementSetter; //导入依赖的package包/类
@Override
public void batchSave(final List<CangoTable> cangoTables) {
    if (cangoTables != null && cangoTables.size() > 0) {
        String insertSql = "insert into cango_table instances_name, table_name, create_time values(?, ?, ?)";
        final Date current = getCurrentTime();
        jdbcTemplate.batchUpdate(insertSql, new BatchPreparedStatementSetter() {
            @Override
            public void setValues(PreparedStatement ps, int i) throws SQLException {
                CangoTable cangoTable = cangoTables.get(i);
                ps.setString(1, cangoTable.getInstancesName());
                ps.setString(2, cangoTable.getTableName());
                ps.setDate(3, current);
            }

            @Override
            public int getBatchSize() {
                return cangoTables.size();
            }
        });
    }
}
 
开发者ID:kevinKaiF,项目名称:cango,代码行数:22,代码来源:CangoTableServiceImpl.java

示例11: save

import org.springframework.jdbc.core.BatchPreparedStatementSetter; //导入依赖的package包/类
public void save(List<DbSellingOrder> orders) {
	for (int i = 0; i < orders.size(); i += INSERT_BATCH_SIZE) {
		final List<DbSellingOrder> batchList = orders.subList(i,
				i + INSERT_BATCH_SIZE > orders.size() ? orders.size() : i + INSERT_BATCH_SIZE);

		jdbcTpl.batchUpdate(SQL_insert, new BatchPreparedStatementSetter() {
			@Override
			public void setValues(PreparedStatement ps, int j) throws SQLException {
				DbSellingOrder o = batchList.get(j);
				ps.setString(1, o.getProductId());
				ps.setLong(2, o.getCustomerId());
				ps.setDate(3, new Date(o.getOrderDate().getTime()));
				ps.setInt(4, o.getQuantity());
				ps.setLong(5, o.getRevenue());
				ps.setFloat(6, o.getDiscount());
			}

			@Override
			public int getBatchSize() {
				return batchList.size();
			}
		});
	}
}
 
开发者ID:rfxlab,项目名称:vidsell-data-simulator,代码行数:25,代码来源:DbSellingOrderDaoImpl.java

示例12: save

import org.springframework.jdbc.core.BatchPreparedStatementSetter; //导入依赖的package包/类
public void save(List<DbUser> users) {
	for (int i = 0; i < users.size(); i += INSERT_BATCH_SIZE) {
		final List<DbUser> batchList = users.subList(i,
				i + INSERT_BATCH_SIZE > users.size() ? users.size() : i + INSERT_BATCH_SIZE);

		jdbcTpl.batchUpdate(SQL_insert, new BatchPreparedStatementSetter() {
			@Override
			public void setValues(PreparedStatement ps, int j) throws SQLException {
				DbUser u = batchList.get(j);
				ps.setString(1, u.getName());
				ps.setString(2, u.getEmail());
				ps.setInt(3, u.getAge());
				ps.setInt(4, u.getGender());
				ps.setString(5, u.getLocation());
				ps.setTimestamp(6, new Timestamp(u.getCreationDate().getTime()));
				ps.setTimestamp(7, new Timestamp(u.getModification().getTime()));
			}

			@Override
			public int getBatchSize() {
				return batchList.size();
			}
		});
	}
}
 
开发者ID:rfxlab,项目名称:vidsell-data-simulator,代码行数:26,代码来源:DbUserDaoImpl.java

示例13: updateUsers

import org.springframework.jdbc.core.BatchPreparedStatementSetter; //导入依赖的package包/类
/**
 * Exemple d'utilisation d'un BatchPreparedStatementSetter
 *
 * Cette m�thode permet de mettre � jour en masse une liste de users
 */
public int[] updateUsers(final User... usersToUpdate) {
    BatchPreparedStatementSetter bpss = new BatchPreparedStatementSetter() {

        @Override
        public void setValues(final PreparedStatement ps, final int i) throws SQLException {
            User user = usersToUpdate[i];
            ps.setString(1, user.getName());
            ps.setString(2, user.getMail());
            ps.setInt(3, user.getId());
        }

        /**
         * Le batchsize est �gal au nombre d'�l�ment � traiter.
         * S'il est sup�rieur -> ArrayIndexOutOfBoundException
         * S'il est inf�rieur au nombre d'�l�ments � traiter, seuls les n premiers seront trait�s
         *
         * @see org.springframework.jdbc.core.BatchPreparedStatementSetter#getBatchSize()
         */
        @Override
        public int getBatchSize() {
            return usersToUpdate.length;
        }
    };
    return jdbcTemplate.batchUpdate("update users set name = ?, email = ? where id = ?", bpss);
}
 
开发者ID:Eulbobo,项目名称:java-samples,代码行数:31,代码来源:Batch.java

示例14: batchDelete

import org.springframework.jdbc.core.BatchPreparedStatementSetter; //导入依赖的package包/类
@Override
public <T> int[] batchDelete(Class<T> clazz, List<Serializable> ids) {
	//XXX: thinking 共享第一实体的sql
	 TableMapper<T> tableMapper =  DbMappingBuilder.ME.getTableMapper(clazz);
	 String sql  = tableMapper.getDeleteSqlWithId().toString();
	 final List<Serializable> tempids = ids;
	 final int batchSize = ids.size();
	 int[] rows = jdbcTemplate.batchUpdate(sql,new BatchPreparedStatementSetter() {
		
		@Override
		public void setValues(PreparedStatement ps, int i) throws SQLException {
			ps.setObject(1, tempids.get(i));
		}
		
		@Override
		public int getBatchSize() {
			return batchSize;
		}
	});
	return rows;	
}
 
开发者ID:thinking-github,项目名称:nbone,代码行数:22,代码来源:NamedJdbcDao.java

示例15: insertBatch

import org.springframework.jdbc.core.BatchPreparedStatementSetter; //导入依赖的package包/类
@Override
public void insertBatch(final List<Product> products) {
    getJdbcTemplate().batchUpdate(SQL_INSERT, new BatchPreparedStatementSetter() {
        @Override
        public void setValues(PreparedStatement ps, int i) throws SQLException {
            Product product = products.get(i);
            ps.setByte(1, product.getFtiny());
            ps.setShort(2, product.getFsmall());
            ps.setLong(3, product.getFbig());
            ps.setDouble(4, product.getFdouble());
            ps.setTimestamp(5, product.getFdate());
            ps.setInt(6, product.getFyear());
            ps.setString(7, product.getFchar());
            ps.setString(8, product.getFvchar());
            ps.setBigDecimal(9, product.getFdec());
        }

        @Override
        public int getBatchSize() {
            return products.size();
        }
    });
}
 
开发者ID:bMik98,项目名称:spring_jta,代码行数:24,代码来源:ProductDaoJdbc.java


注:本文中的org.springframework.jdbc.core.BatchPreparedStatementSetter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。