public void deleteISOLanguage(
      CFSecurityAuthorization Authorization, CFSecurityISOLanguageBuff Buff) {
    final String S_ProcName = "deleteISOLanguage";
    ResultSet resultSet = null;
    try {
      Connection cnx = schema.getCnx();
      short ISOLanguageId = Buff.getRequiredISOLanguageId();

      final String sql = "CALL sp_delete_iso_lang( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " )";
      if (stmtDeleteByPKey == null) {
        stmtDeleteByPKey = cnx.prepareStatement(sql);
      }
      int argIdx = 1;
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
      stmtDeleteByPKey.setString(
          argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
      stmtDeleteByPKey.setString(
          argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
      stmtDeleteByPKey.setShort(argIdx++, ISOLanguageId);
      stmtDeleteByPKey.setInt(argIdx++, Buff.getRequiredRevision());
      ;
      resultSet = stmtDeleteByPKey.executeQuery();
      if (resultSet.next()) {
        int deleteFlag = resultSet.getInt(1);
        if (resultSet.next()) {
          resultSet.last();
          throw CFLib.getDefaultExceptionFactory()
              .newRuntimeException(
                  getClass(),
                  S_ProcName,
                  "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
        }
      } else {
        throw CFLib.getDefaultExceptionFactory()
            .newRuntimeException(
                getClass(),
                S_ProcName,
                "Expected 1 record result set to be returned by delete, not 0 rows");
      }
    } catch (SQLException e) {
      throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
      if (resultSet != null) {
        try {
          resultSet.close();
        } catch (SQLException e) {
        }
        resultSet = null;
      }
    }
  }
  public void deleteISOLanguage(
      CFSecurityAuthorization Authorization, CFSecurityISOLanguageBuff Buff) {
    final String S_ProcName = "CFInternetRamISOLanguageTable.deleteISOLanguage() ";
    CFSecurityISOLanguagePKey pkey = schema.getFactoryISOLanguage().newPKey();
    pkey.setRequiredISOLanguageId(Buff.getRequiredISOLanguageId());
    CFSecurityISOLanguageBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      return;
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "deleteISOLanguage", pkey);
    }
    CFSecurityISOLanguageByCode3IdxKey keyCode3Idx =
        schema.getFactoryISOLanguage().newCode3IdxKey();
    keyCode3Idx.setRequiredISO6392Code(existing.getRequiredISO6392Code());

    CFSecurityISOLanguageByCode2IdxKey keyCode2Idx =
        schema.getFactoryISOLanguage().newCode2IdxKey();
    keyCode2Idx.setOptionalISO6391Code(existing.getOptionalISO6391Code());

    // Validate reverse foreign keys

    // Delete is valid

    schema
        .getTableISOCountryLanguage()
        .deleteISOCountryLanguageByLanguageIdx(Authorization, Buff.getRequiredISOLanguageId());
    Map<CFSecurityISOLanguagePKey, CFSecurityISOLanguageBuff> subdict;

    dictByPKey.remove(pkey);

    dictByCode3Idx.remove(keyCode3Idx);

    subdict = dictByCode2Idx.get(keyCode2Idx);
    subdict.remove(pkey);
  }
  public void updateISOLanguage(
      CFSecurityAuthorization Authorization, CFSecurityISOLanguageBuff Buff) {
    CFSecurityISOLanguagePKey pkey = schema.getFactoryISOLanguage().newPKey();
    pkey.setRequiredISOLanguageId(Buff.getRequiredISOLanguageId());
    CFSecurityISOLanguageBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newStaleCacheDetectedException(
              getClass(), "updateISOLanguage", "Existing record not found", "ISOLanguage", pkey);
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "updateISOLanguage", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFSecurityISOLanguageByCode3IdxKey existingKeyCode3Idx =
        schema.getFactoryISOLanguage().newCode3IdxKey();
    existingKeyCode3Idx.setRequiredISO6392Code(existing.getRequiredISO6392Code());

    CFSecurityISOLanguageByCode3IdxKey newKeyCode3Idx =
        schema.getFactoryISOLanguage().newCode3IdxKey();
    newKeyCode3Idx.setRequiredISO6392Code(Buff.getRequiredISO6392Code());

    CFSecurityISOLanguageByCode2IdxKey existingKeyCode2Idx =
        schema.getFactoryISOLanguage().newCode2IdxKey();
    existingKeyCode2Idx.setOptionalISO6391Code(existing.getOptionalISO6391Code());

    CFSecurityISOLanguageByCode2IdxKey newKeyCode2Idx =
        schema.getFactoryISOLanguage().newCode2IdxKey();
    newKeyCode2Idx.setOptionalISO6391Code(Buff.getOptionalISO6391Code());

    // Check unique indexes

    if (!existingKeyCode3Idx.equals(newKeyCode3Idx)) {
      if (dictByCode3Idx.containsKey(newKeyCode3Idx)) {
        throw CFLib.getDefaultExceptionFactory()
            .newUniqueIndexViolationException(
                getClass(), "updateISOLanguage", "ISOLanguage6392Idx", newKeyCode3Idx);
      }
    }

    // Validate foreign keys

    // Update is valid

    Map<CFSecurityISOLanguagePKey, CFSecurityISOLanguageBuff> subdict;

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

    dictByCode3Idx.remove(existingKeyCode3Idx);
    dictByCode3Idx.put(newKeyCode3Idx, Buff);

    subdict = dictByCode2Idx.get(existingKeyCode2Idx);
    if (subdict != null) {
      subdict.remove(pkey);
    }
    if (dictByCode2Idx.containsKey(newKeyCode2Idx)) {
      subdict = dictByCode2Idx.get(newKeyCode2Idx);
    } else {
      subdict = new HashMap<CFSecurityISOLanguagePKey, CFSecurityISOLanguageBuff>();
      dictByCode2Idx.put(newKeyCode2Idx, subdict);
    }
    subdict.put(pkey, Buff);
  }
 public void updateISOLanguage(
     CFSecurityAuthorization Authorization, CFSecurityISOLanguageBuff Buff) {
   final String S_ProcName = "updateISOLanguage";
   if ("ISLN".equals(Buff.getClassCode()) && (!schema.isSystemUser(Authorization))) {
     throw CFLib.getDefaultExceptionFactory()
         .newRuntimeException(
             getClass(),
             S_ProcName,
             "Permission denied -- only system user can modify ISOLanguage data");
   }
   ResultSet resultSet = null;
   try {
     short ISOLanguageId = Buff.getRequiredISOLanguageId();
     String ISO6392Code = Buff.getRequiredISO6392Code();
     String ISO6391Code = Buff.getOptionalISO6391Code();
     String EnglishName = Buff.getRequiredEnglishName();
     int Revision = Buff.getRequiredRevision();
     Connection cnx = schema.getCnx();
     final String sql =
         "CALL sp_update_iso_lang( ?, ?, ?, ?, ?, ?"
             + ", "
             + "?"
             + ", "
             + "?"
             + ", "
             + "?"
             + ", "
             + "?"
             + ", "
             + "?"
             + " )";
     if (stmtUpdateByPKey == null) {
       stmtUpdateByPKey = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtUpdateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtUpdateByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtUpdateByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtUpdateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtUpdateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtUpdateByPKey.setString(argIdx++, "ISLN");
     stmtUpdateByPKey.setShort(argIdx++, ISOLanguageId);
     stmtUpdateByPKey.setString(argIdx++, ISO6392Code);
     if (ISO6391Code != null) {
       stmtUpdateByPKey.setString(argIdx++, ISO6391Code);
     } else {
       stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
     }
     stmtUpdateByPKey.setString(argIdx++, EnglishName);
     stmtUpdateByPKey.setInt(argIdx++, Revision);
     resultSet = stmtUpdateByPKey.executeQuery();
     if (resultSet.next()) {
       CFSecurityISOLanguageBuff updatedBuff = unpackISOLanguageResultSetToBuff(resultSet);
       if (resultSet.next()) {
         resultSet.last();
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(
                 getClass(),
                 S_ProcName,
                 "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
       }
       Buff.setRequiredISO6392Code(updatedBuff.getRequiredISO6392Code());
       Buff.setOptionalISO6391Code(updatedBuff.getOptionalISO6391Code());
       Buff.setRequiredEnglishName(updatedBuff.getRequiredEnglishName());
       Buff.setRequiredRevision(updatedBuff.getRequiredRevision());
     } else {
       throw CFLib.getDefaultExceptionFactory()
           .newRuntimeException(
               getClass(),
               S_ProcName,
               "Expected a single-record response, " + resultSet.getRow() + " rows selected");
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }