public CFSecuritySecSessionBuff lockDerived(
     CFSecurityAuthorization Authorization, CFSecuritySecSessionPKey PKey) {
   final String S_ProcName = "CFSecurityRamSecSession.readDerived";
   CFSecuritySecSessionPKey key = schema.getFactorySecSession().newPKey();
   key.setRequiredSecSessionId(PKey.getRequiredSecSessionId());
   CFSecuritySecSessionBuff buff;
   if (dictByPKey.containsKey(key)) {
     buff = dictByPKey.get(key);
   } else {
     buff = null;
   }
   return (buff);
 }
  public void createSecSession(
      CFSecurityAuthorization Authorization, CFSecuritySecSessionBuff Buff) {
    final String S_ProcName = "createSecSession";
    CFSecuritySecSessionPKey pkey = schema.getFactorySecSession().newPKey();
    pkey.setRequiredSecSessionId(schema.nextSecSessionIdGen());
    Buff.setRequiredSecSessionId(pkey.getRequiredSecSessionId());
    CFSecuritySecSessionBySecUserIdxKey keySecUserIdx =
        schema.getFactorySecSession().newSecUserIdxKey();
    keySecUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId());

    CFSecuritySecSessionBySecDevIdxKey keySecDevIdx =
        schema.getFactorySecSession().newSecDevIdxKey();
    keySecDevIdx.setRequiredSecUserId(Buff.getRequiredSecUserId());
    keySecDevIdx.setOptionalSecDevName(Buff.getOptionalSecDevName());

    CFSecuritySecSessionByStartIdxKey keyStartIdx = schema.getFactorySecSession().newStartIdxKey();
    keyStartIdx.setRequiredSecUserId(Buff.getRequiredSecUserId());
    keyStartIdx.setRequiredStart(Buff.getRequiredStart());

    CFSecuritySecSessionByFinishIdxKey keyFinishIdx =
        schema.getFactorySecSession().newFinishIdxKey();
    keyFinishIdx.setRequiredSecUserId(Buff.getRequiredSecUserId());
    keyFinishIdx.setOptionalFinish(Buff.getOptionalFinish());

    CFSecuritySecSessionBySecProxyIdxKey keySecProxyIdx =
        schema.getFactorySecSession().newSecProxyIdxKey();
    keySecProxyIdx.setOptionalSecProxyId(Buff.getOptionalSecProxyId());

    // Validate unique indexes

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

    if (dictByStartIdx.containsKey(keyStartIdx)) {
      throw CFLib.getDefaultExceptionFactory()
          .newUniqueIndexViolationException(getClass(), S_ProcName, "SessionStartIdx", keyStartIdx);
    }

    // Validate foreign keys

    {
      boolean allNull = true;
      allNull = false;
      if (!allNull) {
        if (null
            == schema
                .getTableSecUser()
                .readDerivedByIdIdx(Authorization, Buff.getRequiredSecUserId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), S_ProcName, "Container", "SecSessionUser", "SecUser", null);
        }
      }
    }

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    Map<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff> subdictSecUserIdx;
    if (dictBySecUserIdx.containsKey(keySecUserIdx)) {
      subdictSecUserIdx = dictBySecUserIdx.get(keySecUserIdx);
    } else {
      subdictSecUserIdx = new HashMap<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff>();
      dictBySecUserIdx.put(keySecUserIdx, subdictSecUserIdx);
    }
    subdictSecUserIdx.put(pkey, Buff);

    Map<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff> subdictSecDevIdx;
    if (dictBySecDevIdx.containsKey(keySecDevIdx)) {
      subdictSecDevIdx = dictBySecDevIdx.get(keySecDevIdx);
    } else {
      subdictSecDevIdx = new HashMap<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff>();
      dictBySecDevIdx.put(keySecDevIdx, subdictSecDevIdx);
    }
    subdictSecDevIdx.put(pkey, Buff);

    dictByStartIdx.put(keyStartIdx, Buff);

    Map<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff> subdictFinishIdx;
    if (dictByFinishIdx.containsKey(keyFinishIdx)) {
      subdictFinishIdx = dictByFinishIdx.get(keyFinishIdx);
    } else {
      subdictFinishIdx = new HashMap<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff>();
      dictByFinishIdx.put(keyFinishIdx, subdictFinishIdx);
    }
    subdictFinishIdx.put(pkey, Buff);

    Map<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff> subdictSecProxyIdx;
    if (dictBySecProxyIdx.containsKey(keySecProxyIdx)) {
      subdictSecProxyIdx = dictBySecProxyIdx.get(keySecProxyIdx);
    } else {
      subdictSecProxyIdx = new HashMap<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff>();
      dictBySecProxyIdx.put(keySecProxyIdx, subdictSecProxyIdx);
    }
    subdictSecProxyIdx.put(pkey, Buff);
  }