Пример #1
0
    public Deafness mapRow(ResultSet rs, int rowNum) throws SQLException {
      Deafness deafness = new Deafness();

      deafness.setId(rs.getLong(ID_FIELD_NAME));
      deafness.setRadarNo(rs.getLong(RADAR_NO_FIELD_NAME));
      deafness.setEvidenceOfDeafness(
          Deafness.EvidenceOfDeafness.getEvidenceOfDeafness(
              rs.getInt(EVIDENCE_OF_DEAFNESS_FIELD_NAME)));
      deafness.setDateProblemFirstNoticed(rs.getDate(DATE_PROBLEM_FIRST_NOTICED_FIELD_NAME));
      deafness.setDateStartedUsingHearingAid(rs.getDate(DATE_STARTED_USING_HEARING_AID_FIELD_NAME));

      return deafness;
    }
Пример #2
0
  public void save(Deafness deafness) {
    Map<String, Object> geneticsMap = new HashMap<String, Object>();
    geneticsMap.put(ID_FIELD_NAME, deafness.getId());
    geneticsMap.put(RADAR_NO_FIELD_NAME, deafness.getRadarNo());
    geneticsMap.put(EVIDENCE_OF_DEAFNESS_FIELD_NAME, deafness.getEvidenceOfDeafness().getId());
    geneticsMap.put(DATE_PROBLEM_FIRST_NOTICED_FIELD_NAME, deafness.getDateProblemFirstNoticed());
    geneticsMap.put(
        DATE_STARTED_USING_HEARING_AID_FIELD_NAME, deafness.getDateStartedUsingHearingAid());

    if (deafness.hasValidId()) {
      namedParameterJdbcTemplate.update(
          buildUpdateQuery(TABLE_NAME, ID_FIELD_NAME, geneticsMap), geneticsMap);
    } else {
      Number id = deafnessInsert.executeAndReturnKey(geneticsMap);
      deafness.setId(id.longValue());
    }
  }