(PropertyBusinessObject cmp)
| 374 | /// |
| 375 | /// - `IOException` |
| 376 | public void update(PropertyBusinessObject cmp) throws IOException { |
| 377 | String pkName = (String) cmp.getPropertyIndex().getMetaDataOfClass("cn1$pk"); |
| 378 | if (pkName == null) { |
| 379 | throw new IOException("Primary key required for update"); |
| 380 | } |
| 381 | String tableName = getTableName(cmp); |
| 382 | StringBuilder createStatement = new StringBuilder("UPDATE "); |
| 383 | createStatement.append(tableName); |
| 384 | createStatement.append(" SET "); |
| 385 | |
| 386 | int count = 0; |
| 387 | ArrayList<Object> values = new ArrayList<Object>(); |
| 388 | for (PropertyBase p : cmp.getPropertyIndex()) { |
| 389 | SqlType tp = getSqlType(p); |
| 390 | if (tp == SqlType.SQL_EXCLUDE) { |
| 391 | continue; |
| 392 | } |
| 393 | if (count > 0) { |
| 394 | createStatement.append(","); |
| 395 | } |
| 396 | if (p instanceof Property) { |
| 397 | values.add(tp.asUpdateInsertValue(p.get(), (Property) p)); |
| 398 | } else { |
| 399 | // TODO |
| 400 | values.add(null); |
| 401 | } |
| 402 | count++; |
| 403 | String columnName = getColumnName(p); |
| 404 | createStatement.append(columnName); |
| 405 | createStatement.append(" = ?"); |
| 406 | } |
| 407 | |
| 408 | createStatement.append(" WHERE "); |
| 409 | |
| 410 | createStatement.append(pkName); |
| 411 | createStatement.append(" = ?"); |
| 412 | |
| 413 | Property p = (Property) cmp.getPropertyIndex().getIgnoreCase(pkName); |
| 414 | values.add(p.get()); |
| 415 | |
| 416 | execute(createStatement.toString(), values.toArray()); |
| 417 | } |
| 418 | |
| 419 | /// Deletes a table row matching the component |
| 420 | /// |
nothing calls this directly
no test coverage detected