コード例 #1
0
  /**
   * Sauvegarde le couple distances/blasons en base.
   *
   * @see org.ajdeveloppement.commons.sql.SqlPersistance#save()
   * @throws SqlPersistanceException
   */
  @SuppressWarnings("nls")
  @Override
  public void save() throws SqlPersistanceException {
    criteriaSet.save();

    Map<String, Object> fk = new HashMap<String, Object>();
    fk.put("NUMREGLEMENT", criteriaSet.getReglement().getNumReglement()); // $NON-NLS-1$
    fk.put("NUMBLASON", targetFace.getNumblason());
    fk.put("NUMCRITERIASET", criteriaSet.getNumCriteriaSet());
    helper.save(this, fk);

    try {
      Statement stmt = ApplicationCore.dbConnection.createStatement();
      try {
        stmt.executeUpdate(
            "delete from DISTANCES where NUMDISTANCESBLASONS="
                + numdistancesblason
                + " and NUMREGLEMENT="
                + criteriaSet.getReglement().getNumReglement());
        int i = 1;
        for (int distance : distances) {
          stmt.executeUpdate(
              "insert into DISTANCES (NUMDISTANCES, NUMDISTANCESBLASONS, NUMREGLEMENT, DISTANCE) "
                  + //$NON-NLS-1$
                  "VALUES ("
                  + (i++)
                  + ", "
                  + numdistancesblason
                  + ", "
                  + criteriaSet.getReglement().getNumReglement()
                  + ", "
                  + distance
                  + ")");
        }
      } finally {
        stmt.close();
      }
    } catch (SQLException e) {
      throw new SqlPersistanceException(e);
    }
  }