コード例 #1
0
 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);
 }
コード例 #2
0
 public String generateSelectOneByPrimaryKeyCommand(Object key)
     throws NotImplementedTypesException {
   return "select * from "
       + tableName
       + " where "
       + primaryKeyFieldConverter.getName()
       + " = "
       + stringValueOf(key);
 }
コード例 #3
0
 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();
 }
コード例 #4
0
 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()));
     }
   }
 }