public ICFCrmMemoObj readMemoByUDescrIdx(
     long TenantId, long ContactId, String Description, boolean forceRead) {
   if (indexByUDescrIdx == null) {
     indexByUDescrIdx = new HashMap<CFCrmMemoByUDescrIdxKey, ICFCrmMemoObj>();
   }
   CFCrmMemoByUDescrIdxKey key =
       ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newUDescrIdxKey();
   key.setRequiredTenantId(TenantId);
   key.setRequiredContactId(ContactId);
   key.setRequiredDescription(Description);
   ICFCrmMemoObj obj = null;
   if ((!forceRead) && indexByUDescrIdx.containsKey(key)) {
     obj = indexByUDescrIdx.get(key);
   } else {
     CFCrmMemoBuff buff =
         ((ICFAccSchema) schema.getBackingStore())
             .getTableMemo()
             .readDerivedByUDescrIdx(schema.getAuthorization(), TenantId, ContactId, Description);
     if (buff != null) {
       obj = schema.getMemoTableObj().newInstance();
       obj.setPKey(((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newPKey());
       obj.setBuff(buff);
       obj = (ICFCrmMemoObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       indexByUDescrIdx.put(key, null);
     }
   }
   return (obj);
 }
 public ICFSecurityTSecGroupMemberObj readTSecGroupMemberByUUserIdx(
     long TenantId, int TSecGroupId, UUID SecUserId, boolean forceRead) {
   if (indexByUUserIdx == null) {
     indexByUUserIdx =
         new HashMap<CFSecurityTSecGroupMemberByUUserIdxKey, ICFSecurityTSecGroupMemberObj>();
   }
   CFSecurityTSecGroupMemberByUUserIdxKey key =
       ((ICFBamSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newUUserIdxKey();
   key.setRequiredTenantId(TenantId);
   key.setRequiredTSecGroupId(TSecGroupId);
   key.setRequiredSecUserId(SecUserId);
   ICFSecurityTSecGroupMemberObj obj = null;
   if ((!forceRead) && indexByUUserIdx.containsKey(key)) {
     obj = indexByUUserIdx.get(key);
   } else {
     CFSecurityTSecGroupMemberBuff buff =
         ((ICFBamSchema) schema.getBackingStore())
             .getTableTSecGroupMember()
             .readDerivedByUUserIdx(schema.getAuthorization(), TenantId, TSecGroupId, SecUserId);
     if (buff != null) {
       obj = schema.getTSecGroupMemberTableObj().newInstance();
       obj.setPKey(
           ((ICFBamSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newPKey());
       obj.setBuff(buff);
       obj = (ICFSecurityTSecGroupMemberObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       indexByUUserIdx.put(key, null);
     }
   }
   return (obj);
 }
 public ICFBamClearTopDepObj readClearTopDepByUNameIdx(
     long TenantId, long ContTableId, String Name, boolean forceRead) {
   if (indexByUNameIdx == null) {
     indexByUNameIdx = new HashMap<CFBamClearTopDepByUNameIdxKey, ICFBamClearTopDepObj>();
   }
   CFBamClearTopDepByUNameIdxKey key =
       schema.getBackingStore().getFactoryClearTopDep().newUNameIdxKey();
   key.setRequiredTenantId(TenantId);
   key.setRequiredContTableId(ContTableId);
   key.setRequiredName(Name);
   ICFBamClearTopDepObj obj = null;
   if ((!forceRead) && indexByUNameIdx.containsKey(key)) {
     obj = indexByUNameIdx.get(key);
   } else {
     CFBamClearTopDepBuff buff =
         schema
             .getBackingStore()
             .getTableClearTopDep()
             .readDerivedByUNameIdx(schema.getAuthorization(), TenantId, ContTableId, Name);
     if (buff != null) {
       obj =
           (ICFBamClearTopDepObj)
               schema.getScopeTableObj().constructByClassCode(buff.getClassCode());
       obj.setPKey(schema.getBackingStore().getFactoryScope().newPKey());
       obj.setBuff(buff);
       obj = (ICFBamClearTopDepObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       indexByUNameIdx.put(key, null);
     }
   }
   return (obj);
 }
 public ICFSecurityISOCountryCurrencyObj readISOCountryCurrency(
     CFSecurityISOCountryCurrencyPKey pkey, boolean forceRead) {
   ICFSecurityISOCountryCurrencyObj obj = null;
   if ((!forceRead) && members.containsKey(pkey)) {
     obj = members.get(pkey);
   } else {
     CFSecurityISOCountryCurrencyBuff readBuff =
         ((ICFInternetSchema) schema.getBackingStore())
             .getTableISOCountryCurrency()
             .readDerivedByIdIdx(
                 schema.getAuthorization(),
                 pkey.getRequiredISOCountryId(),
                 pkey.getRequiredISOCurrencyId());
     if (readBuff != null) {
       obj = schema.getISOCountryCurrencyTableObj().newInstance();
       obj.setPKey(
           ((ICFInternetSchema) schema.getBackingStore())
               .getFactoryISOCountryCurrency()
               .newPKey());
       obj.setBuff(readBuff);
       obj = (ICFSecurityISOCountryCurrencyObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       members.put(pkey, null);
     }
   }
   return (obj);
 }
 public ICFSecurityTSecGroupMemberObj readTSecGroupMember(
     CFSecurityTSecGroupMemberPKey pkey, boolean forceRead) {
   ICFSecurityTSecGroupMemberObj obj = null;
   if ((!forceRead) && members.containsKey(pkey)) {
     obj = members.get(pkey);
   } else {
     CFSecurityTSecGroupMemberBuff readBuff =
         ((ICFBamSchema) schema.getBackingStore())
             .getTableTSecGroupMember()
             .readDerivedByIdIdx(
                 schema.getAuthorization(),
                 pkey.getRequiredTenantId(),
                 pkey.getRequiredTSecGroupMemberId());
     if (readBuff != null) {
       obj = schema.getTSecGroupMemberTableObj().newInstance();
       obj.setPKey(
           ((ICFBamSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newPKey());
       obj.setBuff(readBuff);
       obj = (ICFSecurityTSecGroupMemberObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       members.put(pkey, null);
     }
   }
   return (obj);
 }
  public void createISOCurrency(CFBamAuthorization Authorization, CFBamISOCurrencyBuff Buff) {
    final String S_ProcName = "createISOCurrency";
    CFBamISOCurrencyPKey pkey = schema.getFactoryISOCurrency().newPKey();
    pkey.setRequiredId(Buff.getRequiredId());
    Buff.setRequiredId(pkey.getRequiredId());
    CFBamISOCurrencyByCcyCdIdxKey keyCcyCdIdx = schema.getFactoryISOCurrency().newCcyCdIdxKey();
    keyCcyCdIdx.setRequiredISOCode(Buff.getRequiredISOCode());

    CFBamISOCurrencyByCcyNmIdxKey keyCcyNmIdx = schema.getFactoryISOCurrency().newCcyNmIdxKey();
    keyCcyNmIdx.setRequiredName(Buff.getRequiredName());

    // Validate unique indexes

    if (dictByPKey.containsKey(pkey)) {
      throw CFLib.getDefaultExceptionFactory()
          .newPrimaryKeyNotNewException(getClass(), S_ProcName, pkey);
    }

    if (dictByCcyCdIdx.containsKey(keyCcyCdIdx)) {
      throw CFLib.getDefaultExceptionFactory()
          .newUniqueIndexViolationException(
              getClass(), S_ProcName, "ISOCurrencyCodeIdx", keyCcyCdIdx);
    }

    if (dictByCcyNmIdx.containsKey(keyCcyNmIdx)) {
      throw CFLib.getDefaultExceptionFactory()
          .newUniqueIndexViolationException(
              getClass(), S_ProcName, "ISOCurrencyNameIdx", keyCcyNmIdx);
    }

    // Validate foreign keys

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    dictByCcyCdIdx.put(keyCcyCdIdx, Buff);

    dictByCcyNmIdx.put(keyCcyNmIdx, Buff);
  }
 public ICFCrmMemoObj readMemo(CFCrmMemoPKey pkey, boolean forceRead) {
   ICFCrmMemoObj obj = null;
   if ((!forceRead) && members.containsKey(pkey)) {
     obj = members.get(pkey);
   } else {
     CFCrmMemoBuff readBuff =
         ((ICFAccSchema) schema.getBackingStore())
             .getTableMemo()
             .readDerivedByIdIdx(
                 schema.getAuthorization(), pkey.getRequiredTenantId(), pkey.getRequiredMemoId());
     if (readBuff != null) {
       obj = schema.getMemoTableObj().newInstance();
       obj.setPKey(((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newPKey());
       obj.setBuff(readBuff);
       obj = (ICFCrmMemoObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       members.put(pkey, null);
     }
   }
   return (obj);
 }
  public void updateNumberDef(CFSecurityAuthorization Authorization, CFDbTestNumberDefBuff Buff) {
    schema.getTableAtom().updateAtom(Authorization, Buff);
    CFDbTestValuePKey pkey = schema.getFactoryValue().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredId(Buff.getRequiredId());
    CFDbTestNumberDefBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newStaleCacheDetectedException(
              getClass(), "updateNumberDef", "Existing record not found", "NumberDef", pkey);
    }
    // Check unique indexes

    // Validate foreign keys

    {
      boolean allNull = true;

      if (allNull) {
        if (null
            == schema
                .getTableAtom()
                .readDerivedByIdIdx(
                    Authorization, Buff.getRequiredTenantId(), Buff.getRequiredId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), "updateNumberDef", "Superclass", "SuperClass", "Atom", null);
        }
      }
    }

    // Update is valid

    Map<CFDbTestValuePKey, CFDbTestNumberDefBuff> subdict;

    dictByPKey.remove(pkey);
    dictByPKey.put(pkey, Buff);
  }
  public void createNumberDef(CFSecurityAuthorization Authorization, CFDbTestNumberDefBuff Buff) {
    final String S_ProcName = "createNumberDef";
    schema.getTableAtom().createAtom(Authorization, Buff);
    CFDbTestValuePKey pkey = schema.getFactoryValue().newPKey();
    pkey.setClassCode(Buff.getClassCode());
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredId(Buff.getRequiredId());
    // Validate unique indexes

    if (dictByPKey.containsKey(pkey)) {
      throw CFLib.getDefaultExceptionFactory()
          .newPrimaryKeyNotNewException(getClass(), S_ProcName, pkey);
    }

    // Validate foreign keys

    {
      boolean allNull = true;
      allNull = false;
      allNull = false;
      if (!allNull) {
        if (null
            == schema
                .getTableAtom()
                .readDerivedByIdIdx(
                    Authorization, Buff.getRequiredTenantId(), Buff.getRequiredId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), S_ProcName, "Superclass", "SuperClass", "Atom", null);
        }
      }
    }

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);
  }
 public ICFBamClearTopDepObj readClearTopDep(CFBamScopePKey pkey, boolean forceRead) {
   ICFBamClearTopDepObj obj = null;
   if ((!forceRead) && members.containsKey(pkey)) {
     obj = members.get(pkey);
   } else {
     CFBamClearTopDepBuff readBuff =
         schema
             .getBackingStore()
             .getTableClearTopDep()
             .readDerivedByIdIdx(
                 schema.getAuthorization(), pkey.getRequiredTenantId(), pkey.getRequiredId());
     if (readBuff != null) {
       obj =
           (ICFBamClearTopDepObj)
               schema.getScopeTableObj().constructByClassCode(readBuff.getClassCode());
       obj.setPKey(schema.getBackingStore().getFactoryScope().newPKey());
       obj.setBuff(readBuff);
       obj = (ICFBamClearTopDepObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       members.put(pkey, null);
     }
   }
   return (obj);
 }
  public void updateHostNode(CFSecurityAuthorization Authorization, CFSecurityHostNodeBuff Buff) {
    CFSecurityHostNodePKey pkey = schema.getFactoryHostNode().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredHostNodeId(Buff.getRequiredHostNodeId());
    CFSecurityHostNodeBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newStaleCacheDetectedException(
              getClass(), "updateHostNode", "Existing record not found", "HostNode", pkey);
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "updateHostNode", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFSecurityHostNodeByClusterIdxKey existingKeyClusterIdx =
        schema.getFactoryHostNode().newClusterIdxKey();
    existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

    CFSecurityHostNodeByClusterIdxKey newKeyClusterIdx =
        schema.getFactoryHostNode().newClusterIdxKey();
    newKeyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

    CFSecurityHostNodeByUDescrIdxKey existingKeyUDescrIdx =
        schema.getFactoryHostNode().newUDescrIdxKey();
    existingKeyUDescrIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeyUDescrIdx.setRequiredDescription(existing.getRequiredDescription());

    CFSecurityHostNodeByUDescrIdxKey newKeyUDescrIdx =
        schema.getFactoryHostNode().newUDescrIdxKey();
    newKeyUDescrIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyUDescrIdx.setRequiredDescription(Buff.getRequiredDescription());

    CFSecurityHostNodeByHostNameIdxKey existingKeyHostNameIdx =
        schema.getFactoryHostNode().newHostNameIdxKey();
    existingKeyHostNameIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeyHostNameIdx.setRequiredHostName(existing.getRequiredHostName());

    CFSecurityHostNodeByHostNameIdxKey newKeyHostNameIdx =
        schema.getFactoryHostNode().newHostNameIdxKey();
    newKeyHostNameIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyHostNameIdx.setRequiredHostName(Buff.getRequiredHostName());

    // Check unique indexes

    if (!existingKeyUDescrIdx.equals(newKeyUDescrIdx)) {
      if (dictByUDescrIdx.containsKey(newKeyUDescrIdx)) {
        throw CFLib.getDefaultExceptionFactory()
            .newUniqueIndexViolationException(
                getClass(), "updateHostNode", "HostNodeUDescrIdx", newKeyUDescrIdx);
      }
    }

    if (!existingKeyHostNameIdx.equals(newKeyHostNameIdx)) {
      if (dictByHostNameIdx.containsKey(newKeyHostNameIdx)) {
        throw CFLib.getDefaultExceptionFactory()
            .newUniqueIndexViolationException(
                getClass(), "updateHostNode", "HostNodeUHostNameIdx", newKeyHostNameIdx);
      }
    }

    // Validate foreign keys

    {
      boolean allNull = true;

      if (allNull) {
        if (null
            == schema
                .getTableCluster()
                .readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), "updateHostNode", "Container", "HostNodeCluster", "Cluster", null);
        }
      }
    }

    // Update is valid

    Map<CFSecurityHostNodePKey, CFSecurityHostNodeBuff> subdict;

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

    subdict = dictByClusterIdx.get(existingKeyClusterIdx);
    if (subdict != null) {
      subdict.remove(pkey);
    }
    if (dictByClusterIdx.containsKey(newKeyClusterIdx)) {
      subdict = dictByClusterIdx.get(newKeyClusterIdx);
    } else {
      subdict = new HashMap<CFSecurityHostNodePKey, CFSecurityHostNodeBuff>();
      dictByClusterIdx.put(newKeyClusterIdx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByUDescrIdx.remove(existingKeyUDescrIdx);
    dictByUDescrIdx.put(newKeyUDescrIdx, Buff);

    dictByHostNameIdx.remove(existingKeyHostNameIdx);
    dictByHostNameIdx.put(newKeyHostNameIdx, Buff);
  }
  public void updateISOCurrency(CFBamAuthorization Authorization, CFBamISOCurrencyBuff Buff) {
    CFBamISOCurrencyPKey pkey = schema.getFactoryISOCurrency().newPKey();
    pkey.setRequiredId(Buff.getRequiredId());
    CFBamISOCurrencyBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newStaleCacheDetectedException(
              getClass(), "updateISOCurrency", "Existing record not found", "ISOCurrency", pkey);
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "updateISOCurrency", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFBamISOCurrencyByCcyCdIdxKey existingKeyCcyCdIdx =
        schema.getFactoryISOCurrency().newCcyCdIdxKey();
    existingKeyCcyCdIdx.setRequiredISOCode(existing.getRequiredISOCode());

    CFBamISOCurrencyByCcyCdIdxKey newKeyCcyCdIdx = schema.getFactoryISOCurrency().newCcyCdIdxKey();
    newKeyCcyCdIdx.setRequiredISOCode(Buff.getRequiredISOCode());

    CFBamISOCurrencyByCcyNmIdxKey existingKeyCcyNmIdx =
        schema.getFactoryISOCurrency().newCcyNmIdxKey();
    existingKeyCcyNmIdx.setRequiredName(existing.getRequiredName());

    CFBamISOCurrencyByCcyNmIdxKey newKeyCcyNmIdx = schema.getFactoryISOCurrency().newCcyNmIdxKey();
    newKeyCcyNmIdx.setRequiredName(Buff.getRequiredName());

    // Check unique indexes

    if (!existingKeyCcyCdIdx.equals(newKeyCcyCdIdx)) {
      if (dictByCcyCdIdx.containsKey(newKeyCcyCdIdx)) {
        throw CFLib.getDefaultExceptionFactory()
            .newUniqueIndexViolationException(
                getClass(), "updateISOCurrency", "ISOCurrencyCodeIdx", newKeyCcyCdIdx);
      }
    }

    if (!existingKeyCcyNmIdx.equals(newKeyCcyNmIdx)) {
      if (dictByCcyNmIdx.containsKey(newKeyCcyNmIdx)) {
        throw CFLib.getDefaultExceptionFactory()
            .newUniqueIndexViolationException(
                getClass(), "updateISOCurrency", "ISOCurrencyNameIdx", newKeyCcyNmIdx);
      }
    }

    // Validate foreign keys

    // Update is valid

    Map<CFBamISOCurrencyPKey, CFBamISOCurrencyBuff> subdict;

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

    dictByCcyCdIdx.remove(existingKeyCcyCdIdx);
    dictByCcyCdIdx.put(newKeyCcyCdIdx, Buff);

    dictByCcyNmIdx.remove(existingKeyCcyNmIdx);
    dictByCcyNmIdx.put(newKeyCcyNmIdx, Buff);
  }
  public void createDelSubDep3(CFBamAuthorization Authorization, CFBamDelSubDep3Buff Buff) {
    final String S_ProcName = "createDelSubDep3";
    schema.getTableDelDep().createDelDep(Authorization, Buff);
    CFBamScopePKey pkey = schema.getFactoryScope().newPKey();
    pkey.setClassCode(Buff.getClassCode());
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredId(Buff.getRequiredId());
    CFBamDelSubDep3ByContDelDep2IdxKey keyContDelDep2Idx =
        schema.getFactoryDelSubDep3().newContDelDep2IdxKey();
    keyContDelDep2Idx.setRequiredContTenantId(Buff.getRequiredContTenantId());
    keyContDelDep2Idx.setRequiredContDelDep2Id(Buff.getRequiredContDelDep2Id());

    CFBamDelSubDep3ByUNameIdxKey keyUNameIdx = schema.getFactoryDelSubDep3().newUNameIdxKey();
    keyUNameIdx.setRequiredContTenantId(Buff.getRequiredContTenantId());
    keyUNameIdx.setRequiredContDelDep2Id(Buff.getRequiredContDelDep2Id());
    keyUNameIdx.setRequiredName(Buff.getRequiredName());

    // Validate unique indexes

    if (dictByPKey.containsKey(pkey)) {
      throw CFLib.getDefaultExceptionFactory()
          .newPrimaryKeyNotNewException(getClass(), S_ProcName, pkey);
    }

    if (dictByUNameIdx.containsKey(keyUNameIdx)) {
      throw CFLib.getDefaultExceptionFactory()
          .newUniqueIndexViolationException(
              getClass(), S_ProcName, "DelSubDep3UNameIdx", keyUNameIdx);
    }

    // Validate foreign keys

    {
      boolean allNull = true;
      allNull = false;
      allNull = false;
      if (!allNull) {
        if (null
            == schema
                .getTableDelDep()
                .readDerivedByIdIdx(
                    Authorization, Buff.getRequiredTenantId(), Buff.getRequiredId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), S_ProcName, "Superclass", "SuperClass", "DelDep", null);
        }
      }
    }

    {
      boolean allNull = true;
      allNull = false;
      allNull = false;
      if (!allNull) {
        if (null
            == schema
                .getTableDelSubDep2()
                .readDerivedByIdIdx(
                    Authorization,
                    Buff.getRequiredContTenantId(),
                    Buff.getRequiredContDelDep2Id())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), S_ProcName, "Container", "ContDelSubDep3", "DelSubDep2", null);
        }
      }
    }

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    Map<CFBamScopePKey, CFBamDelSubDep3Buff> subdictContDelDep2Idx;
    if (dictByContDelDep2Idx.containsKey(keyContDelDep2Idx)) {
      subdictContDelDep2Idx = dictByContDelDep2Idx.get(keyContDelDep2Idx);
    } else {
      subdictContDelDep2Idx = new HashMap<CFBamScopePKey, CFBamDelSubDep3Buff>();
      dictByContDelDep2Idx.put(keyContDelDep2Idx, subdictContDelDep2Idx);
    }
    subdictContDelDep2Idx.put(pkey, Buff);

    dictByUNameIdx.put(keyUNameIdx, Buff);
  }
  public void updateDelSubDep3(CFBamAuthorization Authorization, CFBamDelSubDep3Buff Buff) {
    schema.getTableDelDep().updateDelDep(Authorization, Buff);
    CFBamScopePKey pkey = schema.getFactoryScope().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredId(Buff.getRequiredId());
    CFBamDelSubDep3Buff existing = dictByPKey.get(pkey);
    if (existing == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newStaleCacheDetectedException(
              getClass(), "updateDelSubDep3", "Existing record not found", "DelSubDep3", pkey);
    }
    CFBamDelSubDep3ByContDelDep2IdxKey existingKeyContDelDep2Idx =
        schema.getFactoryDelSubDep3().newContDelDep2IdxKey();
    existingKeyContDelDep2Idx.setRequiredContTenantId(existing.getRequiredContTenantId());
    existingKeyContDelDep2Idx.setRequiredContDelDep2Id(existing.getRequiredContDelDep2Id());

    CFBamDelSubDep3ByContDelDep2IdxKey newKeyContDelDep2Idx =
        schema.getFactoryDelSubDep3().newContDelDep2IdxKey();
    newKeyContDelDep2Idx.setRequiredContTenantId(Buff.getRequiredContTenantId());
    newKeyContDelDep2Idx.setRequiredContDelDep2Id(Buff.getRequiredContDelDep2Id());

    CFBamDelSubDep3ByUNameIdxKey existingKeyUNameIdx =
        schema.getFactoryDelSubDep3().newUNameIdxKey();
    existingKeyUNameIdx.setRequiredContTenantId(existing.getRequiredContTenantId());
    existingKeyUNameIdx.setRequiredContDelDep2Id(existing.getRequiredContDelDep2Id());
    existingKeyUNameIdx.setRequiredName(existing.getRequiredName());

    CFBamDelSubDep3ByUNameIdxKey newKeyUNameIdx = schema.getFactoryDelSubDep3().newUNameIdxKey();
    newKeyUNameIdx.setRequiredContTenantId(Buff.getRequiredContTenantId());
    newKeyUNameIdx.setRequiredContDelDep2Id(Buff.getRequiredContDelDep2Id());
    newKeyUNameIdx.setRequiredName(Buff.getRequiredName());

    // Check unique indexes

    if (!existingKeyUNameIdx.equals(newKeyUNameIdx)) {
      if (dictByUNameIdx.containsKey(newKeyUNameIdx)) {
        throw CFLib.getDefaultExceptionFactory()
            .newUniqueIndexViolationException(
                getClass(), "updateDelSubDep3", "DelSubDep3UNameIdx", newKeyUNameIdx);
      }
    }

    // Validate foreign keys

    {
      boolean allNull = true;

      if (allNull) {
        if (null
            == schema
                .getTableDelDep()
                .readDerivedByIdIdx(
                    Authorization, Buff.getRequiredTenantId(), Buff.getRequiredId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), "updateDelSubDep3", "Superclass", "SuperClass", "DelDep", null);
        }
      }
    }

    {
      boolean allNull = true;

      if (allNull) {
        if (null
            == schema
                .getTableDelSubDep2()
                .readDerivedByIdIdx(
                    Authorization,
                    Buff.getRequiredContTenantId(),
                    Buff.getRequiredContDelDep2Id())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(),
                  "updateDelSubDep3",
                  "Container",
                  "ContDelSubDep3",
                  "DelSubDep2",
                  null);
        }
      }
    }

    // Update is valid

    Map<CFBamScopePKey, CFBamDelSubDep3Buff> subdict;

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

    subdict = dictByContDelDep2Idx.get(existingKeyContDelDep2Idx);
    if (subdict != null) {
      subdict.remove(pkey);
    }
    if (dictByContDelDep2Idx.containsKey(newKeyContDelDep2Idx)) {
      subdict = dictByContDelDep2Idx.get(newKeyContDelDep2Idx);
    } else {
      subdict = new HashMap<CFBamScopePKey, CFBamDelSubDep3Buff>();
      dictByContDelDep2Idx.put(newKeyContDelDep2Idx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByUNameIdx.remove(existingKeyUNameIdx);
    dictByUNameIdx.put(newKeyUNameIdx, Buff);
  }
  public void createSecGroupForm(
      CFSecurityAuthorization Authorization, CFSecuritySecGroupFormBuff Buff) {
    final String S_ProcName = "createSecGroupForm";
    CFSecuritySecGroupFormPKey pkey = schema.getFactorySecGroupForm().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredSecGroupFormId(
        ((CFInternetRamClusterTable) schema.getTableCluster())
            .nextSecGroupFormIdGen(Authorization, Buff.getRequiredClusterId()));
    Buff.setRequiredClusterId(pkey.getRequiredClusterId());
    Buff.setRequiredSecGroupFormId(pkey.getRequiredSecGroupFormId());
    CFSecuritySecGroupFormByClusterIdxKey keyClusterIdx =
        schema.getFactorySecGroupForm().newClusterIdxKey();
    keyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

    CFSecuritySecGroupFormByGroupIdxKey keyGroupIdx =
        schema.getFactorySecGroupForm().newGroupIdxKey();
    keyGroupIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    keyGroupIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());

    CFSecuritySecGroupFormByAppIdxKey keyAppIdx = schema.getFactorySecGroupForm().newAppIdxKey();
    keyAppIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    keyAppIdx.setRequiredSecAppId(Buff.getRequiredSecAppId());

    CFSecuritySecGroupFormByFormIdxKey keyFormIdx = schema.getFactorySecGroupForm().newFormIdxKey();
    keyFormIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    keyFormIdx.setRequiredSecFormId(Buff.getRequiredSecFormId());

    CFSecuritySecGroupFormByUFormIdxKey keyUFormIdx =
        schema.getFactorySecGroupForm().newUFormIdxKey();
    keyUFormIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    keyUFormIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());
    keyUFormIdx.setRequiredSecFormId(Buff.getRequiredSecFormId());

    // Validate unique indexes

    if (dictByPKey.containsKey(pkey)) {
      throw CFLib.getDefaultExceptionFactory()
          .newPrimaryKeyNotNewException(getClass(), S_ProcName, pkey);
    }

    if (dictByUFormIdx.containsKey(keyUFormIdx)) {
      throw CFLib.getDefaultExceptionFactory()
          .newUniqueIndexViolationException(
              getClass(), S_ProcName, "SecGroupFormUFormIdx", keyUFormIdx);
    }

    // Validate foreign keys

    {
      boolean allNull = true;
      allNull = false;
      if (!allNull) {
        if (null
            == schema
                .getTableCluster()
                .readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), S_ProcName, "Owner", "SecGroupFormCluster", "Cluster", null);
        }
      }
    }

    {
      boolean allNull = true;
      allNull = false;
      allNull = false;
      if (!allNull) {
        if (null
            == schema
                .getTableSecGroup()
                .readDerivedByIdIdx(
                    Authorization, Buff.getRequiredClusterId(), Buff.getRequiredSecGroupId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), S_ProcName, "Container", "SecGroupFormGroup", "SecGroup", null);
        }
      }
    }

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    Map<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff> subdictClusterIdx;
    if (dictByClusterIdx.containsKey(keyClusterIdx)) {
      subdictClusterIdx = dictByClusterIdx.get(keyClusterIdx);
    } else {
      subdictClusterIdx = new HashMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff>();
      dictByClusterIdx.put(keyClusterIdx, subdictClusterIdx);
    }
    subdictClusterIdx.put(pkey, Buff);

    Map<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff> subdictGroupIdx;
    if (dictByGroupIdx.containsKey(keyGroupIdx)) {
      subdictGroupIdx = dictByGroupIdx.get(keyGroupIdx);
    } else {
      subdictGroupIdx = new HashMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff>();
      dictByGroupIdx.put(keyGroupIdx, subdictGroupIdx);
    }
    subdictGroupIdx.put(pkey, Buff);

    Map<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff> subdictAppIdx;
    if (dictByAppIdx.containsKey(keyAppIdx)) {
      subdictAppIdx = dictByAppIdx.get(keyAppIdx);
    } else {
      subdictAppIdx = new HashMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff>();
      dictByAppIdx.put(keyAppIdx, subdictAppIdx);
    }
    subdictAppIdx.put(pkey, Buff);

    Map<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff> subdictFormIdx;
    if (dictByFormIdx.containsKey(keyFormIdx)) {
      subdictFormIdx = dictByFormIdx.get(keyFormIdx);
    } else {
      subdictFormIdx = new HashMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff>();
      dictByFormIdx.put(keyFormIdx, subdictFormIdx);
    }
    subdictFormIdx.put(pkey, Buff);

    dictByUFormIdx.put(keyUFormIdx, Buff);
  }
  public ICFSecurityISOCountryCurrencyObj realizeISOCountryCurrency(
      ICFSecurityISOCountryCurrencyObj Obj) {
    ICFSecurityISOCountryCurrencyObj obj = Obj;
    CFSecurityISOCountryCurrencyPKey pkey = obj.getPKey();
    ICFSecurityISOCountryCurrencyObj keepObj = null;
    if (members.containsKey(pkey) && (null != members.get(pkey))) {
      ICFSecurityISOCountryCurrencyObj existingObj = members.get(pkey);
      keepObj = existingObj;

      /*
       *	We always rebind the data because if we're being called, some index has
       *	been updated and is refreshing it's data, which may or may not have changed
       */

      // Detach object from alternate and duplicate indexes, leave PKey alone

      if (indexByCountryIdx != null) {
        CFSecurityISOCountryCurrencyByCountryIdxKey keyCountryIdx =
            ((ICFInternetSchema) schema.getBackingStore())
                .getFactoryISOCountryCurrency()
                .newCountryIdxKey();
        keyCountryIdx.setRequiredISOCountryId(keepObj.getRequiredISOCountryId());
        Map<CFSecurityISOCountryCurrencyPKey, ICFSecurityISOCountryCurrencyObj> mapCountryIdx =
            indexByCountryIdx.get(keyCountryIdx);
        if (mapCountryIdx != null) {
          mapCountryIdx.remove(keepObj.getPKey());
        }
      }

      if (indexByCurrencyIdx != null) {
        CFSecurityISOCountryCurrencyByCurrencyIdxKey keyCurrencyIdx =
            ((ICFInternetSchema) schema.getBackingStore())
                .getFactoryISOCountryCurrency()
                .newCurrencyIdxKey();
        keyCurrencyIdx.setRequiredISOCurrencyId(keepObj.getRequiredISOCurrencyId());
        Map<CFSecurityISOCountryCurrencyPKey, ICFSecurityISOCountryCurrencyObj> mapCurrencyIdx =
            indexByCurrencyIdx.get(keyCurrencyIdx);
        if (mapCurrencyIdx != null) {
          mapCurrencyIdx.remove(keepObj.getPKey());
        }
      }

      keepObj.setBuff(Obj.getBuff());
      // Attach new object to alternate and duplicate indexes -- PKey stay stable

      if (indexByCountryIdx != null) {
        CFSecurityISOCountryCurrencyByCountryIdxKey keyCountryIdx =
            ((ICFInternetSchema) schema.getBackingStore())
                .getFactoryISOCountryCurrency()
                .newCountryIdxKey();
        keyCountryIdx.setRequiredISOCountryId(keepObj.getRequiredISOCountryId());
        Map<CFSecurityISOCountryCurrencyPKey, ICFSecurityISOCountryCurrencyObj> mapCountryIdx =
            indexByCountryIdx.get(keyCountryIdx);
        if (mapCountryIdx != null) {
          mapCountryIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByCurrencyIdx != null) {
        CFSecurityISOCountryCurrencyByCurrencyIdxKey keyCurrencyIdx =
            ((ICFInternetSchema) schema.getBackingStore())
                .getFactoryISOCountryCurrency()
                .newCurrencyIdxKey();
        keyCurrencyIdx.setRequiredISOCurrencyId(keepObj.getRequiredISOCurrencyId());
        Map<CFSecurityISOCountryCurrencyPKey, ICFSecurityISOCountryCurrencyObj> mapCurrencyIdx =
            indexByCurrencyIdx.get(keyCurrencyIdx);
        if (mapCurrencyIdx != null) {
          mapCurrencyIdx.put(keepObj.getPKey(), keepObj);
        }
      }
      if (allISOCountryCurrency != null) {
        allISOCountryCurrency.put(keepObj.getPKey(), keepObj);
      }
    } else {
      keepObj = obj;
      keepObj.setIsNew(false);
      // Attach new object to PKey, all, alternate, and duplicate indexes
      members.put(keepObj.getPKey(), keepObj);
      if (allISOCountryCurrency != null) {
        allISOCountryCurrency.put(keepObj.getPKey(), keepObj);
      }

      if (indexByCountryIdx != null) {
        CFSecurityISOCountryCurrencyByCountryIdxKey keyCountryIdx =
            ((ICFInternetSchema) schema.getBackingStore())
                .getFactoryISOCountryCurrency()
                .newCountryIdxKey();
        keyCountryIdx.setRequiredISOCountryId(keepObj.getRequiredISOCountryId());
        Map<CFSecurityISOCountryCurrencyPKey, ICFSecurityISOCountryCurrencyObj> mapCountryIdx =
            indexByCountryIdx.get(keyCountryIdx);
        if (mapCountryIdx != null) {
          mapCountryIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByCurrencyIdx != null) {
        CFSecurityISOCountryCurrencyByCurrencyIdxKey keyCurrencyIdx =
            ((ICFInternetSchema) schema.getBackingStore())
                .getFactoryISOCountryCurrency()
                .newCurrencyIdxKey();
        keyCurrencyIdx.setRequiredISOCurrencyId(keepObj.getRequiredISOCurrencyId());
        Map<CFSecurityISOCountryCurrencyPKey, ICFSecurityISOCountryCurrencyObj> mapCurrencyIdx =
            indexByCurrencyIdx.get(keyCurrencyIdx);
        if (mapCurrencyIdx != null) {
          mapCurrencyIdx.put(keepObj.getPKey(), keepObj);
        }
      }
    }
    return (keepObj);
  }
  public ICFBamClearTopDepObj realizeClearTopDep(ICFBamClearTopDepObj Obj) {
    ICFBamClearTopDepObj obj = Obj;
    CFBamScopePKey pkey = obj.getPKey();
    ICFBamClearTopDepObj keepObj = null;
    if (members.containsKey(pkey) && (null != members.get(pkey))) {
      ICFBamClearTopDepObj existingObj = members.get(pkey);
      keepObj = existingObj;

      /*
       *	We always rebind the data because if we're being called, some index has
       *	been updated and is refreshing it's data, which may or may not have changed
       */

      // Detach object from alternate and duplicate indexes, leave PKey alone

      if (indexByTenantIdx != null) {
        CFBamScopeByTenantIdxKey keyTenantIdx =
            schema.getBackingStore().getFactoryScope().newTenantIdxKey();
        keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        Map<CFBamScopePKey, ICFBamClearTopDepObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx);
        if (mapTenantIdx != null) {
          indexByTenantIdx.remove(keyTenantIdx);
        }
      }

      if (indexByTableIdx != null) {
        CFBamClearDepByTableIdxKey keyTableIdx =
            schema.getBackingStore().getFactoryClearDep().newTableIdxKey();
        keyTableIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyTableIdx.setRequiredRelationId(keepObj.getRequiredRelationId());
        Map<CFBamScopePKey, ICFBamClearTopDepObj> mapTableIdx = indexByTableIdx.get(keyTableIdx);
        if (mapTableIdx != null) {
          indexByTableIdx.remove(keyTableIdx);
        }
      }

      if (indexByContTblIdx != null) {
        CFBamClearTopDepByContTblIdxKey keyContTblIdx =
            schema.getBackingStore().getFactoryClearTopDep().newContTblIdxKey();
        keyContTblIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyContTblIdx.setRequiredContTableId(keepObj.getRequiredContTableId());
        Map<CFBamScopePKey, ICFBamClearTopDepObj> mapContTblIdx =
            indexByContTblIdx.get(keyContTblIdx);
        if (mapContTblIdx != null) {
          mapContTblIdx.remove(keepObj.getPKey());
        }
      }

      if (indexByUNameIdx != null) {
        CFBamClearTopDepByUNameIdxKey keyUNameIdx =
            schema.getBackingStore().getFactoryClearTopDep().newUNameIdxKey();
        keyUNameIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyUNameIdx.setRequiredContTableId(keepObj.getRequiredContTableId());
        keyUNameIdx.setRequiredName(keepObj.getRequiredName());
        indexByUNameIdx.remove(keyUNameIdx);
      }
      // Keep passing the new object because it's the one with the buffer
      // that the base table needs to copy to the existing object from
      // the cache.
      keepObj = (ICFBamClearTopDepObj) schema.getClearDepTableObj().realizeClearDep(Obj);

      // Attach new object to alternate and duplicate indexes -- PKey stay stable

      if (indexByTenantIdx != null) {
        CFBamScopeByTenantIdxKey keyTenantIdx =
            schema.getBackingStore().getFactoryScope().newTenantIdxKey();
        keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        Map<CFBamScopePKey, ICFBamClearTopDepObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx);
        if (mapTenantIdx != null) {
          mapTenantIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByTableIdx != null) {
        CFBamClearDepByTableIdxKey keyTableIdx =
            schema.getBackingStore().getFactoryClearDep().newTableIdxKey();
        keyTableIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyTableIdx.setRequiredRelationId(keepObj.getRequiredRelationId());
        Map<CFBamScopePKey, ICFBamClearTopDepObj> mapTableIdx = indexByTableIdx.get(keyTableIdx);
        if (mapTableIdx != null) {
          mapTableIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByContTblIdx != null) {
        CFBamClearTopDepByContTblIdxKey keyContTblIdx =
            schema.getBackingStore().getFactoryClearTopDep().newContTblIdxKey();
        keyContTblIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyContTblIdx.setRequiredContTableId(keepObj.getRequiredContTableId());
        Map<CFBamScopePKey, ICFBamClearTopDepObj> mapContTblIdx =
            indexByContTblIdx.get(keyContTblIdx);
        if (mapContTblIdx != null) {
          mapContTblIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByUNameIdx != null) {
        CFBamClearTopDepByUNameIdxKey keyUNameIdx =
            schema.getBackingStore().getFactoryClearTopDep().newUNameIdxKey();
        keyUNameIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyUNameIdx.setRequiredContTableId(keepObj.getRequiredContTableId());
        keyUNameIdx.setRequiredName(keepObj.getRequiredName());
        indexByUNameIdx.put(keyUNameIdx, keepObj);
      }
      if (allClearTopDep != null) {
        allClearTopDep.put(keepObj.getPKey(), keepObj);
      }
    } else {
      keepObj = obj;
      keepObj = (ICFBamClearTopDepObj) schema.getClearDepTableObj().realizeClearDep(keepObj);
      // Attach new object to PKey, all, alternate, and duplicate indexes
      members.put(keepObj.getPKey(), keepObj);
      if (allClearTopDep != null) {
        allClearTopDep.put(keepObj.getPKey(), keepObj);
      }

      if (indexByTenantIdx != null) {
        CFBamScopeByTenantIdxKey keyTenantIdx =
            schema.getBackingStore().getFactoryScope().newTenantIdxKey();
        keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        Map<CFBamScopePKey, ICFBamClearTopDepObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx);
        if (mapTenantIdx != null) {
          mapTenantIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByTableIdx != null) {
        CFBamClearDepByTableIdxKey keyTableIdx =
            schema.getBackingStore().getFactoryClearDep().newTableIdxKey();
        keyTableIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyTableIdx.setRequiredRelationId(keepObj.getRequiredRelationId());
        Map<CFBamScopePKey, ICFBamClearTopDepObj> mapTableIdx = indexByTableIdx.get(keyTableIdx);
        if (mapTableIdx != null) {
          mapTableIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByContTblIdx != null) {
        CFBamClearTopDepByContTblIdxKey keyContTblIdx =
            schema.getBackingStore().getFactoryClearTopDep().newContTblIdxKey();
        keyContTblIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyContTblIdx.setRequiredContTableId(keepObj.getRequiredContTableId());
        Map<CFBamScopePKey, ICFBamClearTopDepObj> mapContTblIdx =
            indexByContTblIdx.get(keyContTblIdx);
        if (mapContTblIdx != null) {
          mapContTblIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByUNameIdx != null) {
        CFBamClearTopDepByUNameIdxKey keyUNameIdx =
            schema.getBackingStore().getFactoryClearTopDep().newUNameIdxKey();
        keyUNameIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyUNameIdx.setRequiredContTableId(keepObj.getRequiredContTableId());
        keyUNameIdx.setRequiredName(keepObj.getRequiredName());
        indexByUNameIdx.put(keyUNameIdx, keepObj);
      }
    }
    return (keepObj);
  }
  public void updateTSecGroupMember(
      CFSecurityAuthorization Authorization, CFSecurityTSecGroupMemberBuff Buff) {
    CFSecurityTSecGroupMemberPKey pkey = schema.getFactoryTSecGroupMember().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredTSecGroupMemberId(Buff.getRequiredTSecGroupMemberId());
    CFSecurityTSecGroupMemberBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newStaleCacheDetectedException(
              getClass(),
              "updateTSecGroupMember",
              "Existing record not found",
              "TSecGroupMember",
              pkey);
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "updateTSecGroupMember", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFSecurityTSecGroupMemberByTenantIdxKey existingKeyTenantIdx =
        schema.getFactoryTSecGroupMember().newTenantIdxKey();
    existingKeyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId());

    CFSecurityTSecGroupMemberByTenantIdxKey newKeyTenantIdx =
        schema.getFactoryTSecGroupMember().newTenantIdxKey();
    newKeyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    CFSecurityTSecGroupMemberByGroupIdxKey existingKeyGroupIdx =
        schema.getFactoryTSecGroupMember().newGroupIdxKey();
    existingKeyGroupIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyGroupIdx.setRequiredTSecGroupId(existing.getRequiredTSecGroupId());

    CFSecurityTSecGroupMemberByGroupIdxKey newKeyGroupIdx =
        schema.getFactoryTSecGroupMember().newGroupIdxKey();
    newKeyGroupIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyGroupIdx.setRequiredTSecGroupId(Buff.getRequiredTSecGroupId());

    CFSecurityTSecGroupMemberByUserIdxKey existingKeyUserIdx =
        schema.getFactoryTSecGroupMember().newUserIdxKey();
    existingKeyUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId());

    CFSecurityTSecGroupMemberByUserIdxKey newKeyUserIdx =
        schema.getFactoryTSecGroupMember().newUserIdxKey();
    newKeyUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId());

    CFSecurityTSecGroupMemberByUUserIdxKey existingKeyUUserIdx =
        schema.getFactoryTSecGroupMember().newUUserIdxKey();
    existingKeyUUserIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyUUserIdx.setRequiredTSecGroupId(existing.getRequiredTSecGroupId());
    existingKeyUUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId());

    CFSecurityTSecGroupMemberByUUserIdxKey newKeyUUserIdx =
        schema.getFactoryTSecGroupMember().newUUserIdxKey();
    newKeyUUserIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyUUserIdx.setRequiredTSecGroupId(Buff.getRequiredTSecGroupId());
    newKeyUUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId());

    // Check unique indexes

    if (!existingKeyUUserIdx.equals(newKeyUUserIdx)) {
      if (dictByUUserIdx.containsKey(newKeyUUserIdx)) {
        throw CFLib.getDefaultExceptionFactory()
            .newUniqueIndexViolationException(
                getClass(), "updateTSecGroupMember", "TSecGroupMemberUUserIdx", newKeyUUserIdx);
      }
    }

    // Validate foreign keys

    {
      boolean allNull = true;

      if (allNull) {
        if (null
            == schema
                .getTableTenant()
                .readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(),
                  "updateTSecGroupMember",
                  "Owner",
                  "TSecGroupMemberTenant",
                  "Tenant",
                  null);
        }
      }
    }

    {
      boolean allNull = true;

      if (allNull) {
        if (null
            == schema
                .getTableTSecGroup()
                .readDerivedByIdIdx(
                    Authorization, Buff.getRequiredTenantId(), Buff.getRequiredTSecGroupId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(),
                  "updateTSecGroupMember",
                  "Container",
                  "TSecGroupMemberGroup",
                  "TSecGroup",
                  null);
        }
      }
    }

    // Update is valid

    Map<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff> subdict;

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

    subdict = dictByTenantIdx.get(existingKeyTenantIdx);
    if (subdict != null) {
      subdict.remove(pkey);
    }
    if (dictByTenantIdx.containsKey(newKeyTenantIdx)) {
      subdict = dictByTenantIdx.get(newKeyTenantIdx);
    } else {
      subdict = new HashMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff>();
      dictByTenantIdx.put(newKeyTenantIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByGroupIdx.get(existingKeyGroupIdx);
    if (subdict != null) {
      subdict.remove(pkey);
    }
    if (dictByGroupIdx.containsKey(newKeyGroupIdx)) {
      subdict = dictByGroupIdx.get(newKeyGroupIdx);
    } else {
      subdict = new HashMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff>();
      dictByGroupIdx.put(newKeyGroupIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByUserIdx.get(existingKeyUserIdx);
    if (subdict != null) {
      subdict.remove(pkey);
    }
    if (dictByUserIdx.containsKey(newKeyUserIdx)) {
      subdict = dictByUserIdx.get(newKeyUserIdx);
    } else {
      subdict = new HashMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff>();
      dictByUserIdx.put(newKeyUserIdx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByUUserIdx.remove(existingKeyUUserIdx);
    dictByUUserIdx.put(newKeyUUserIdx, Buff);
  }
  public ICFCrmMemoObj realizeMemo(ICFCrmMemoObj Obj) {
    ICFCrmMemoObj obj = Obj;
    CFCrmMemoPKey pkey = obj.getPKey();
    ICFCrmMemoObj keepObj = null;
    if (members.containsKey(pkey) && (null != members.get(pkey))) {
      ICFCrmMemoObj existingObj = members.get(pkey);
      keepObj = existingObj;

      /*
       *	We always rebind the data because if we're being called, some index has
       *	been updated and is refreshing it's data, which may or may not have changed
       */

      // Detach object from alternate and duplicate indexes, leave PKey alone

      if (indexByTenantIdx != null) {
        CFCrmMemoByTenantIdxKey keyTenantIdx =
            ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newTenantIdxKey();
        keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        Map<CFCrmMemoPKey, ICFCrmMemoObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx);
        if (mapTenantIdx != null) {
          mapTenantIdx.remove(keepObj.getPKey());
        }
      }

      if (indexByMemoContactIdx != null) {
        CFCrmMemoByMemoContactIdxKey keyMemoContactIdx =
            ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newMemoContactIdxKey();
        keyMemoContactIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyMemoContactIdx.setRequiredContactId(keepObj.getRequiredContactId());
        Map<CFCrmMemoPKey, ICFCrmMemoObj> mapMemoContactIdx =
            indexByMemoContactIdx.get(keyMemoContactIdx);
        if (mapMemoContactIdx != null) {
          mapMemoContactIdx.remove(keepObj.getPKey());
        }
      }

      if (indexByUDescrIdx != null) {
        CFCrmMemoByUDescrIdxKey keyUDescrIdx =
            ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newUDescrIdxKey();
        keyUDescrIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyUDescrIdx.setRequiredContactId(keepObj.getRequiredContactId());
        keyUDescrIdx.setRequiredDescription(keepObj.getRequiredDescription());
        indexByUDescrIdx.remove(keyUDescrIdx);
      }

      keepObj.setBuff(Obj.getBuff());
      // Attach new object to alternate and duplicate indexes -- PKey stay stable

      if (indexByTenantIdx != null) {
        CFCrmMemoByTenantIdxKey keyTenantIdx =
            ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newTenantIdxKey();
        keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        Map<CFCrmMemoPKey, ICFCrmMemoObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx);
        if (mapTenantIdx != null) {
          mapTenantIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByMemoContactIdx != null) {
        CFCrmMemoByMemoContactIdxKey keyMemoContactIdx =
            ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newMemoContactIdxKey();
        keyMemoContactIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyMemoContactIdx.setRequiredContactId(keepObj.getRequiredContactId());
        Map<CFCrmMemoPKey, ICFCrmMemoObj> mapMemoContactIdx =
            indexByMemoContactIdx.get(keyMemoContactIdx);
        if (mapMemoContactIdx != null) {
          mapMemoContactIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByUDescrIdx != null) {
        CFCrmMemoByUDescrIdxKey keyUDescrIdx =
            ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newUDescrIdxKey();
        keyUDescrIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyUDescrIdx.setRequiredContactId(keepObj.getRequiredContactId());
        keyUDescrIdx.setRequiredDescription(keepObj.getRequiredDescription());
        indexByUDescrIdx.put(keyUDescrIdx, keepObj);
      }
      if (allMemo != null) {
        allMemo.put(keepObj.getPKey(), keepObj);
      }
    } else {
      keepObj = obj;
      keepObj.setIsNew(false);
      // Attach new object to PKey, all, alternate, and duplicate indexes
      members.put(keepObj.getPKey(), keepObj);
      if (allMemo != null) {
        allMemo.put(keepObj.getPKey(), keepObj);
      }

      if (indexByTenantIdx != null) {
        CFCrmMemoByTenantIdxKey keyTenantIdx =
            ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newTenantIdxKey();
        keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        Map<CFCrmMemoPKey, ICFCrmMemoObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx);
        if (mapTenantIdx != null) {
          mapTenantIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByMemoContactIdx != null) {
        CFCrmMemoByMemoContactIdxKey keyMemoContactIdx =
            ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newMemoContactIdxKey();
        keyMemoContactIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyMemoContactIdx.setRequiredContactId(keepObj.getRequiredContactId());
        Map<CFCrmMemoPKey, ICFCrmMemoObj> mapMemoContactIdx =
            indexByMemoContactIdx.get(keyMemoContactIdx);
        if (mapMemoContactIdx != null) {
          mapMemoContactIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByUDescrIdx != null) {
        CFCrmMemoByUDescrIdxKey keyUDescrIdx =
            ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newUDescrIdxKey();
        keyUDescrIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyUDescrIdx.setRequiredContactId(keepObj.getRequiredContactId());
        keyUDescrIdx.setRequiredDescription(keepObj.getRequiredDescription());
        indexByUDescrIdx.put(keyUDescrIdx, keepObj);
      }
    }
    return (keepObj);
  }
  public void createTSecGroupMember(
      CFSecurityAuthorization Authorization, CFSecurityTSecGroupMemberBuff Buff) {
    final String S_ProcName = "createTSecGroupMember";
    CFSecurityTSecGroupMemberPKey pkey = schema.getFactoryTSecGroupMember().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredTSecGroupMemberId(
        ((CFSecurityRamTenantTable) schema.getTableTenant())
            .nextTSecGroupMemberIdGen(Authorization, Buff.getRequiredTenantId()));
    Buff.setRequiredTenantId(pkey.getRequiredTenantId());
    Buff.setRequiredTSecGroupMemberId(pkey.getRequiredTSecGroupMemberId());
    CFSecurityTSecGroupMemberByTenantIdxKey keyTenantIdx =
        schema.getFactoryTSecGroupMember().newTenantIdxKey();
    keyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    CFSecurityTSecGroupMemberByGroupIdxKey keyGroupIdx =
        schema.getFactoryTSecGroupMember().newGroupIdxKey();
    keyGroupIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    keyGroupIdx.setRequiredTSecGroupId(Buff.getRequiredTSecGroupId());

    CFSecurityTSecGroupMemberByUserIdxKey keyUserIdx =
        schema.getFactoryTSecGroupMember().newUserIdxKey();
    keyUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId());

    CFSecurityTSecGroupMemberByUUserIdxKey keyUUserIdx =
        schema.getFactoryTSecGroupMember().newUUserIdxKey();
    keyUUserIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    keyUUserIdx.setRequiredTSecGroupId(Buff.getRequiredTSecGroupId());
    keyUUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId());

    // Validate unique indexes

    if (dictByPKey.containsKey(pkey)) {
      throw CFLib.getDefaultExceptionFactory()
          .newPrimaryKeyNotNewException(getClass(), S_ProcName, pkey);
    }

    if (dictByUUserIdx.containsKey(keyUUserIdx)) {
      throw CFLib.getDefaultExceptionFactory()
          .newUniqueIndexViolationException(
              getClass(), S_ProcName, "TSecGroupMemberUUserIdx", keyUUserIdx);
    }

    // Validate foreign keys

    {
      boolean allNull = true;
      allNull = false;
      if (!allNull) {
        if (null
            == schema
                .getTableTenant()
                .readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), S_ProcName, "Owner", "TSecGroupMemberTenant", "Tenant", null);
        }
      }
    }

    {
      boolean allNull = true;
      allNull = false;
      allNull = false;
      if (!allNull) {
        if (null
            == schema
                .getTableTSecGroup()
                .readDerivedByIdIdx(
                    Authorization, Buff.getRequiredTenantId(), Buff.getRequiredTSecGroupId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), S_ProcName, "Container", "TSecGroupMemberGroup", "TSecGroup", null);
        }
      }
    }

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    Map<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff> subdictTenantIdx;
    if (dictByTenantIdx.containsKey(keyTenantIdx)) {
      subdictTenantIdx = dictByTenantIdx.get(keyTenantIdx);
    } else {
      subdictTenantIdx =
          new HashMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff>();
      dictByTenantIdx.put(keyTenantIdx, subdictTenantIdx);
    }
    subdictTenantIdx.put(pkey, Buff);

    Map<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff> subdictGroupIdx;
    if (dictByGroupIdx.containsKey(keyGroupIdx)) {
      subdictGroupIdx = dictByGroupIdx.get(keyGroupIdx);
    } else {
      subdictGroupIdx = new HashMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff>();
      dictByGroupIdx.put(keyGroupIdx, subdictGroupIdx);
    }
    subdictGroupIdx.put(pkey, Buff);

    Map<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff> subdictUserIdx;
    if (dictByUserIdx.containsKey(keyUserIdx)) {
      subdictUserIdx = dictByUserIdx.get(keyUserIdx);
    } else {
      subdictUserIdx = new HashMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff>();
      dictByUserIdx.put(keyUserIdx, subdictUserIdx);
    }
    subdictUserIdx.put(pkey, Buff);

    dictByUUserIdx.put(keyUUserIdx, Buff);
  }
  public void createHostNode(CFSecurityAuthorization Authorization, CFSecurityHostNodeBuff Buff) {
    final String S_ProcName = "createHostNode";
    CFSecurityHostNodePKey pkey = schema.getFactoryHostNode().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredHostNodeId(
        ((CFAccRamClusterTable) schema.getTableCluster())
            .nextHostNodeIdGen(Authorization, Buff.getRequiredClusterId()));
    Buff.setRequiredClusterId(pkey.getRequiredClusterId());
    Buff.setRequiredHostNodeId(pkey.getRequiredHostNodeId());
    CFSecurityHostNodeByClusterIdxKey keyClusterIdx =
        schema.getFactoryHostNode().newClusterIdxKey();
    keyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

    CFSecurityHostNodeByUDescrIdxKey keyUDescrIdx = schema.getFactoryHostNode().newUDescrIdxKey();
    keyUDescrIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    keyUDescrIdx.setRequiredDescription(Buff.getRequiredDescription());

    CFSecurityHostNodeByHostNameIdxKey keyHostNameIdx =
        schema.getFactoryHostNode().newHostNameIdxKey();
    keyHostNameIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    keyHostNameIdx.setRequiredHostName(Buff.getRequiredHostName());

    // Validate unique indexes

    if (dictByPKey.containsKey(pkey)) {
      throw CFLib.getDefaultExceptionFactory()
          .newPrimaryKeyNotNewException(getClass(), S_ProcName, pkey);
    }

    if (dictByUDescrIdx.containsKey(keyUDescrIdx)) {
      throw CFLib.getDefaultExceptionFactory()
          .newUniqueIndexViolationException(
              getClass(), S_ProcName, "HostNodeUDescrIdx", keyUDescrIdx);
    }

    if (dictByHostNameIdx.containsKey(keyHostNameIdx)) {
      throw CFLib.getDefaultExceptionFactory()
          .newUniqueIndexViolationException(
              getClass(), S_ProcName, "HostNodeUHostNameIdx", keyHostNameIdx);
    }

    // Validate foreign keys

    {
      boolean allNull = true;
      allNull = false;
      if (!allNull) {
        if (null
            == schema
                .getTableCluster()
                .readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), S_ProcName, "Container", "HostNodeCluster", "Cluster", null);
        }
      }
    }

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    Map<CFSecurityHostNodePKey, CFSecurityHostNodeBuff> subdictClusterIdx;
    if (dictByClusterIdx.containsKey(keyClusterIdx)) {
      subdictClusterIdx = dictByClusterIdx.get(keyClusterIdx);
    } else {
      subdictClusterIdx = new HashMap<CFSecurityHostNodePKey, CFSecurityHostNodeBuff>();
      dictByClusterIdx.put(keyClusterIdx, subdictClusterIdx);
    }
    subdictClusterIdx.put(pkey, Buff);

    dictByUDescrIdx.put(keyUDescrIdx, Buff);

    dictByHostNameIdx.put(keyHostNameIdx, Buff);
  }