示例#1
0
 public Platform mapRow(ResultSet rs, int rowNum) throws SQLException {
   Platform p = new PlatformImpl();
   p.setPlatformId(rs.getLong("platformId"));
   p.setPlatformType(PlatformType.get(rs.getString("name")));
   p.setDescription(rs.getString("description"));
   p.setInstrumentModel(rs.getString("instrumentModel"));
   p.setNumContainers(rs.getInt("numContainers"));
   return p;
 }
示例#2
0
  public long save(Platform platform) throws IOException {
    // execute this procedure...
    MapSqlParameterSource params = new MapSqlParameterSource();
    params
        .addValue("name", platform.getPlatformType().getKey())
        .addValue("instrumentModel", platform.getInstrumentModel())
        .addValue("description", platform.getDescription())
        .addValue("numContainers", platform.getNumContainers());

    if (platform.getPlatformId() == null) {
      SimpleJdbcInsert insert =
          new SimpleJdbcInsert(template)
              .withTableName(TABLE_NAME)
              .usingGeneratedKeyColumns("platformId");
      Number newId = insert.executeAndReturnKey(params);
      platform.setPlatformId(newId.longValue());
    } else {
      params.addValue("platformId", platform.getPlatformId());
      NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
      namedTemplate.update(PLATFORM_UPDATE, params);
    }

    return platform.getPlatformId();
  }