public void deleteISOCountryCurrency(
      CFGenKbAuthorization Authorization, CFGenKbISOCountryCurrencyBuff Buff) {
    final String S_ProcName = "CFGenKbRamISOCountryCurrencyTable.deleteISOCountryCurrency() ";
    CFGenKbISOCountryCurrencyPKey pkey = schema.getFactoryISOCountryCurrency().newPKey();
    pkey.setRequiredISOCountryId(Buff.getRequiredISOCountryId());
    pkey.setRequiredISOCurrencyId(Buff.getRequiredISOCurrencyId());
    CFGenKbISOCountryCurrencyBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      return;
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "deleteISOCountryCurrency", pkey);
    }
    CFGenKbISOCountryCurrencyByCountryIdxKey keyCountryIdx =
        schema.getFactoryISOCountryCurrency().newCountryIdxKey();
    keyCountryIdx.setRequiredISOCountryId(existing.getRequiredISOCountryId());

    CFGenKbISOCountryCurrencyByCurrencyIdxKey keyCurrencyIdx =
        schema.getFactoryISOCountryCurrency().newCurrencyIdxKey();
    keyCurrencyIdx.setRequiredISOCurrencyId(existing.getRequiredISOCurrencyId());

    // Validate reverse foreign keys

    // Delete is valid

    Map<CFGenKbISOCountryCurrencyPKey, CFGenKbISOCountryCurrencyBuff> subdict;

    dictByPKey.remove(pkey);

    subdict = dictByCountryIdx.get(keyCountryIdx);
    subdict.remove(pkey);

    subdict = dictByCurrencyIdx.get(keyCurrencyIdx);
    subdict.remove(pkey);
  }
  public void updateISOCountryCurrency(
      CFGenKbAuthorization Authorization, CFGenKbISOCountryCurrencyBuff Buff) {
    CFGenKbISOCountryCurrencyPKey pkey = schema.getFactoryISOCountryCurrency().newPKey();
    pkey.setRequiredISOCountryId(Buff.getRequiredISOCountryId());
    pkey.setRequiredISOCurrencyId(Buff.getRequiredISOCurrencyId());
    CFGenKbISOCountryCurrencyBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newStaleCacheDetectedException(
              getClass(),
              "updateISOCountryCurrency",
              "Existing record not found",
              "ISOCountryCurrency",
              pkey);
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "updateISOCountryCurrency", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFGenKbISOCountryCurrencyByCountryIdxKey existingKeyCountryIdx =
        schema.getFactoryISOCountryCurrency().newCountryIdxKey();
    existingKeyCountryIdx.setRequiredISOCountryId(existing.getRequiredISOCountryId());

    CFGenKbISOCountryCurrencyByCountryIdxKey newKeyCountryIdx =
        schema.getFactoryISOCountryCurrency().newCountryIdxKey();
    newKeyCountryIdx.setRequiredISOCountryId(Buff.getRequiredISOCountryId());

    CFGenKbISOCountryCurrencyByCurrencyIdxKey existingKeyCurrencyIdx =
        schema.getFactoryISOCountryCurrency().newCurrencyIdxKey();
    existingKeyCurrencyIdx.setRequiredISOCurrencyId(existing.getRequiredISOCurrencyId());

    CFGenKbISOCountryCurrencyByCurrencyIdxKey newKeyCurrencyIdx =
        schema.getFactoryISOCountryCurrency().newCurrencyIdxKey();
    newKeyCurrencyIdx.setRequiredISOCurrencyId(Buff.getRequiredISOCurrencyId());

    // Check unique indexes

    // Validate foreign keys

    {
      boolean allNull = true;

      if (allNull) {
        if (null
            == schema
                .getTableISOCountry()
                .readDerivedByIdIdx(Authorization, Buff.getRequiredISOCountryId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(),
                  "updateISOCountryCurrency",
                  "Container",
                  "ISOCountryCurrencyCountry",
                  "ISOCountry",
                  null);
        }
      }
    }

    // Update is valid

    Map<CFGenKbISOCountryCurrencyPKey, CFGenKbISOCountryCurrencyBuff> subdict;

    dictByPKey.remove(pkey);
    dictByPKey.put(pkey, Buff);

    subdict = dictByCountryIdx.get(existingKeyCountryIdx);
    if (subdict != null) {
      subdict.remove(pkey);
    }
    if (dictByCountryIdx.containsKey(newKeyCountryIdx)) {
      subdict = dictByCountryIdx.get(newKeyCountryIdx);
    } else {
      subdict = new HashMap<CFGenKbISOCountryCurrencyPKey, CFGenKbISOCountryCurrencyBuff>();
      dictByCountryIdx.put(newKeyCountryIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByCurrencyIdx.get(existingKeyCurrencyIdx);
    if (subdict != null) {
      subdict.remove(pkey);
    }
    if (dictByCurrencyIdx.containsKey(newKeyCurrencyIdx)) {
      subdict = dictByCurrencyIdx.get(newKeyCurrencyIdx);
    } else {
      subdict = new HashMap<CFGenKbISOCountryCurrencyPKey, CFGenKbISOCountryCurrencyBuff>();
      dictByCurrencyIdx.put(newKeyCurrencyIdx, subdict);
    }
    subdict.put(pkey, Buff);
  }