public void createOptFullRange(
      CFSecurityAuthorization Authorization, CFDbTestOptFullRangeBuff Buff) {
    final String S_ProcName = "createOptFullRange";
    CFDbTestOptFullRangePKey pkey = schema.getFactoryOptFullRange().newPKey();
    pkey.setRequiredId(schema.nextOptFullRangeIdGen());
    Buff.setRequiredId(pkey.getRequiredId());
    CFDbTestOptFullRangeByUDescrIdxKey keyUDescrIdx =
        schema.getFactoryOptFullRange().newUDescrIdxKey();
    keyUDescrIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    keyUDescrIdx.setRequiredDescription(Buff.getRequiredDescription());

    CFDbTestOptFullRangeByTenantIdxKey keyTenantIdx =
        schema.getFactoryOptFullRange().newTenantIdxKey();
    keyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    // 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, "OptFullRangeUDescrIdx", keyUDescrIdx);
    }

    // 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, "Container", "Tenant", "Tenant", null);
        }
      }
    }

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    dictByUDescrIdx.put(keyUDescrIdx, Buff);

    Map<CFDbTestOptFullRangePKey, CFDbTestOptFullRangeBuff> subdictTenantIdx;
    if (dictByTenantIdx.containsKey(keyTenantIdx)) {
      subdictTenantIdx = dictByTenantIdx.get(keyTenantIdx);
    } else {
      subdictTenantIdx = new HashMap<CFDbTestOptFullRangePKey, CFDbTestOptFullRangeBuff>();
      dictByTenantIdx.put(keyTenantIdx, subdictTenantIdx);
    }
    subdictTenantIdx.put(pkey, Buff);
  }
  public void createLoaderBehaviour(
      CFSecurityAuthorization Authorization, CFDbTestLoaderBehaviourBuff Buff) {
    final String S_ProcName = "createLoaderBehaviour";
    CFDbTestLoaderBehaviourPKey pkey = schema.getFactoryLoaderBehaviour().newPKey();
    pkey.setRequiredId(Buff.getRequiredId());
    Buff.setRequiredId(pkey.getRequiredId());
    CFDbTestLoaderBehaviourByUNameIdxKey keyUNameIdx =
        schema.getFactoryLoaderBehaviour().newUNameIdxKey();
    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, "LoaderBehaviourUNameIdx", keyUNameIdx);
    }

    // Validate foreign keys

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    dictByUNameIdx.put(keyUNameIdx, Buff);
  }
  public void updateLoaderBehaviour(
      CFSecurityAuthorization Authorization, CFDbTestLoaderBehaviourBuff Buff) {
    CFDbTestLoaderBehaviourPKey pkey = schema.getFactoryLoaderBehaviour().newPKey();
    pkey.setRequiredId(Buff.getRequiredId());
    CFDbTestLoaderBehaviourBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newStaleCacheDetectedException(
              getClass(),
              "updateLoaderBehaviour",
              "Existing record not found",
              "LoaderBehaviour",
              pkey);
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "updateLoaderBehaviour", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFDbTestLoaderBehaviourByUNameIdxKey existingKeyUNameIdx =
        schema.getFactoryLoaderBehaviour().newUNameIdxKey();
    existingKeyUNameIdx.setRequiredName(existing.getRequiredName());

    CFDbTestLoaderBehaviourByUNameIdxKey newKeyUNameIdx =
        schema.getFactoryLoaderBehaviour().newUNameIdxKey();
    newKeyUNameIdx.setRequiredName(Buff.getRequiredName());

    // Check unique indexes

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

    // Validate foreign keys

    // Update is valid

    Map<CFDbTestLoaderBehaviourPKey, CFDbTestLoaderBehaviourBuff> subdict;

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

    dictByUNameIdx.remove(existingKeyUNameIdx);
    dictByUNameIdx.put(newKeyUNameIdx, Buff);
  }
  public void createCluster(CFSecurityAuthorization Authorization, CFSecurityClusterBuff Buff) {
    final String S_ProcName = "createCluster";
    CFSecurityClusterPKey pkey = schema.getFactoryCluster().newPKey();
    pkey.setRequiredId(schema.nextClusterIdGen());
    Buff.setRequiredId(pkey.getRequiredId());
    CFSecurityClusterByUDomainNameIdxKey keyUDomainNameIdx =
        schema.getFactoryCluster().newUDomainNameIdxKey();
    keyUDomainNameIdx.setRequiredFullDomainName(Buff.getRequiredFullDomainName());

    CFSecurityClusterByUDescrIdxKey keyUDescrIdx = schema.getFactoryCluster().newUDescrIdxKey();
    keyUDescrIdx.setRequiredDescription(Buff.getRequiredDescription());

    // Validate unique indexes

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

    if (dictByUDomainNameIdx.containsKey(keyUDomainNameIdx)) {
      throw CFLib.getDefaultExceptionFactory()
          .newUniqueIndexViolationException(
              getClass(), S_ProcName, "ClusterUDomainNameIdx", keyUDomainNameIdx);
    }

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

    // Validate foreign keys

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    dictByUDomainNameIdx.put(keyUDomainNameIdx, Buff);

    dictByUDescrIdx.put(keyUDescrIdx, Buff);
  }
  protected long generateNextId64(long argId, short argSliceId) {
    CFDbTestRamClusterId64Gen key = new CFDbTestRamClusterId64Gen();
    key.setRequiredId(argId);
    key.setRequiredSliceId(argSliceId);

    CFDbTestRamClusterId64Gen useGen = id64Generator.get(key);
    if (useGen == null) {
      id64Generator.put(key, key);
      useGen = key;
    }

    long retNext = useGen.getNextId();

    return (retNext);
  }
  public void updateOptFullRange(
      CFSecurityAuthorization Authorization, CFDbTestOptFullRangeBuff Buff) {
    CFDbTestOptFullRangePKey pkey = schema.getFactoryOptFullRange().newPKey();
    pkey.setRequiredId(Buff.getRequiredId());
    CFDbTestOptFullRangeBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newStaleCacheDetectedException(
              getClass(), "updateOptFullRange", "Existing record not found", "OptFullRange", pkey);
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "updateOptFullRange", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFDbTestOptFullRangeByUDescrIdxKey existingKeyUDescrIdx =
        schema.getFactoryOptFullRange().newUDescrIdxKey();
    existingKeyUDescrIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyUDescrIdx.setRequiredDescription(existing.getRequiredDescription());

    CFDbTestOptFullRangeByUDescrIdxKey newKeyUDescrIdx =
        schema.getFactoryOptFullRange().newUDescrIdxKey();
    newKeyUDescrIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyUDescrIdx.setRequiredDescription(Buff.getRequiredDescription());

    CFDbTestOptFullRangeByTenantIdxKey existingKeyTenantIdx =
        schema.getFactoryOptFullRange().newTenantIdxKey();
    existingKeyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId());

    CFDbTestOptFullRangeByTenantIdxKey newKeyTenantIdx =
        schema.getFactoryOptFullRange().newTenantIdxKey();
    newKeyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    // Check unique indexes

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

    // Validate foreign keys

    {
      boolean allNull = true;

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

    // Update is valid

    Map<CFDbTestOptFullRangePKey, CFDbTestOptFullRangeBuff> subdict;

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

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

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