public String generateDeleteCommand(T item) throws NotImplementedTypesException {
   StringBuilder builder =
       new StringBuilder().append("delete from ").append(tableName).append(" where ");
   return "delete from "
       + tableName
       + " where "
       + primaryKeyFieldConverter.getName()
       + " = "
       + primaryKeyFieldConverter.stringValueOf(item);
 }
 public String generateSelectOneByPrimaryKeyCommand(Object key)
     throws NotImplementedTypesException {
   return "select * from "
       + tableName
       + " where "
       + primaryKeyFieldConverter.getName()
       + " = "
       + stringValueOf(key);
 }
예제 #3
0
  public int write(int recordCount) throws IOException {
    int counter = 0;

    for (; counter < recordCount; counter++) {
      recordWriter.checkForNewPartition(counter);
      recordWriter.startRecord();
      // write the current record
      for (FieldConverter converter : fieldConverters) {
        converter.setPosition(counter);
        converter.startField();
        converter.writeField();
        converter.endField();
      }
      recordWriter.endRecord();
    }

    return counter;
  }
 public String generateUpdateCommand(T item) throws NotImplementedTypesException {
   StringBuilder builder = new StringBuilder().append("update ").append(tableName).append(" set ");
   for (int i = 0; i + 1 < fields.size(); i++) {
     builder
         .append(fields.get(i).getName())
         .append(" = ")
         .append(fields.get(i).stringValueOf(item))
         .append(", ");
   }
   builder
       .append(fields.get(fields.size() - 1).getName())
       .append(" = ")
       .append(fields.get(fields.size() - 1).stringValueOf(item));
   builder.append(" where ");
   builder
       .append(primaryKeyFieldConverter.getName())
       .append(" = ")
       .append(primaryKeyFieldConverter.stringValueOf(item));
   return builder.toString();
 }
 protected void writeRow(ResultSet set, T item)
     throws java.sql.SQLException, IllegalAccessException {
   for (FieldConverter field : fields) {
     if (field.getField().getType().equals(Integer.class)) {
       field.getField().set(item, set.getInt(field.getName()));
     }
     if (field.getField().getType().equals(String.class)) {
       field.getField().set(item, set.getString(field.getName()));
     }
   }
 }