我有一门课,位置。Location 包含一个 BorderPoint 对象列表,但它可以是一个巨大的列表(20,000 个并非不可能)。用于此的表是 LOCATION 和 BORDERPOINT。
我最初通过从 ESRI Shapefile 导入来填充位置。这是一个代码片段:
try {
while (featureIterator.hasNext()) {
Location location = new Location();
SimpleFeatureImpl feature = (SimpleFeatureImpl) featureIterator.next();
// set the information in location based on stuff in the feature, lets me clean up this
// method a bit
setLocationInfo(location, feature);
List<BorderPoint> borderPointList = getBorderPoints(feature, location);
//saveBorderPoints(location, feature);
location.setBorderPointList(borderPointList);
try {
locationRepository.persist(location);
} catch (RepositoryException e) {
throw new ServiceException("processShapefile() threw RepositoryException", e);
}
}
} finally {
featureIterator.close();
}
由于 List 中有这么多 BorderPoint 对象,但我只是通过在 Location 对象上调用 persist 来保存它们,我可以自动设置某种批处理大小来持久保存 BorderPoints 吗?