private void insertNonPS(
Collection<? extends SimpleFeature> features,
SimpleFeatureType featureType,
Connection cx,
PrimaryKey key,
boolean useExisting)
throws IOException, SQLException {
if (features.isEmpty()) {
return;
}
final Statement st = cx.createStatement();
final KeysFetcher keysFetcher = KeysFetcher.create(this, cx, useExisting, key);
try {
for (SimpleFeature feature : features) {
String sql = insertSQL(featureType, feature, keysFetcher, cx);
((BasicSQLDialect) dialect).onInsert(st, cx, featureType);
LOGGER.log(Level.FINE, "Inserting new feature: {0}", sql);
if (keysFetcher.hasAutoGeneratedKeys()) {
st.executeUpdate(sql, Statement.RETURN_GENERATED_KEYS);
} else {
st.executeUpdate(sql);
}
keysFetcher.postInsert(featureType, feature, cx, st);
}
} finally {
closeSafe(st);
}
}