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)
| 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 "); |
nothing calls this directly
no test coverage detected