MCPcopy Index your code
hub / github.com/apache/groovy / add

Method add

subprojects/groovy-sql/src/main/java/groovy/sql/DataSet.java:317–333  ·  view source on GitHub ↗

Adds the provided map of key-value pairs as a new row in the table represented by this DataSet. The map values are bound as JDBC parameters, but the map keys are used as column names and included directly in the generated SQL. Treat the keys as trusted SQL identifiers; do not u

(Map<String, Object> map)

Source from the content-addressed store, hash-verified

315 * @throws SQLException if a database error occurs
316 */
317 public void add(Map<String, Object> map) throws SQLException {
318 if (withinDataSetBatch) {
319 if (batchData.isEmpty()) {
320 batchKeys = map.keySet();
321 } else {
322 if (!map.keySet().equals(batchKeys)) {
323 throw new IllegalArgumentException("Inconsistent keys found for batch add!");
324 }
325 }
326 batchData.add(map);
327 return;
328 }
329 int answer = executeUpdate(buildListQuery(map), new ArrayList<Object>(map.values()));
330 if (answer != 1) {
331 LOG.warning("Should have updated 1 row not " + answer + " when trying to add: " + map);
332 }
333 }
334
335 private String buildListQuery(Map<String, Object> map) {
336 StringBuilder buffer = new StringBuilder("insert into ");

Callers

nothing calls this directly

Calls 7

buildListQueryMethod · 0.95
executeUpdateMethod · 0.80
equalsMethod · 0.65
addMethod · 0.65
valuesMethod · 0.65
isEmptyMethod · 0.45
keySetMethod · 0.45

Tested by

no test coverage detected