/** Internal method to read an existing pkg from the database */
  synchronized AreaOfInterest read(String id, Connection conn) throws Exception {
    // check cache
    AreaOfInterest pkg = (AreaOfInterest) cache.get(id);
    if (pkg != null) {
      return pkg;
    }
    // pull from database and populate the object
    PreparedStatement pstmt =
        conn.prepareStatement("SELECT * FROM AreaOfInterest WHERE guid LIKE ?");
    pstmt.setString(1, id);
    ResultSet rs = pstmt.executeQuery();
    pkg = new AreaOfInterest(id);
    if (rs.next()) {
      pkg.setObjectAlreadyInDB(true);
      pkg.setDirty(false);
      pkg.setDescription(rs.getString(2));

    } else {
      throw new DataException("bad AreaOfInterest read");
    }
    pkg.setDirty(false);
    pkg.setObjectAlreadyInDB(true);
    // put in the cache

    cache.put(pkg.getId(), pkg);

    // return the object

    return pkg;
  } // read
  /** Inserts pkg new pkg into the database */
  private void insert(AreaOfInterest pkg, Connection conn) throws Exception {
    PreparedStatement pstmt = conn.prepareStatement("INSERT INTO AreaOfInterest VALUES (?,?)");
    pstmt.setString(1, pkg.getId());
    pstmt.setString(2, pkg.getDescription());

    int numUpd = pstmt.executeUpdate();

    if (numUpd == 1) {
      pkg.setObjectAlreadyInDB(true);
      pkg.setDirty(false);
    } else {
      throw new DataException("bad AreaOfInterest update");
    }
    pstmt.close();
  }
  /** Saves an existing pkg to the database */
  private void update(AreaOfInterest pkg, Connection conn) throws Exception {
    PreparedStatement pstmt =
        conn.prepareStatement("UPDATE AreaOfInterest SET description=? WHERE guid LIKE ?");

    pstmt.setString(1, pkg.getDescription());
    pstmt.setString(2, pkg.getId());

    int numUpd = pstmt.executeUpdate();

    if (numUpd == 1) {
      pkg.setObjectAlreadyInDB(true);
      pkg.setDirty(false);
    } else {
      throw new DataException("bad AreaOfInterest update");
    }

    pstmt.close();
  }