public void deleteSecSessionByStartIdx(
     CFSecurityAuthorization Authorization, CFSecuritySecSessionByStartIdxKey argKey) {
   CFSecuritySecSessionBuff cur;
   LinkedList<CFSecuritySecSessionBuff> matchSet = new LinkedList<CFSecuritySecSessionBuff>();
   Iterator<CFSecuritySecSessionBuff> values = dictByPKey.values().iterator();
   while (values.hasNext()) {
     cur = values.next();
     if (argKey.equals(cur)) {
       matchSet.add(cur);
     }
   }
   Iterator<CFSecuritySecSessionBuff> iterMatch = matchSet.iterator();
   while (iterMatch.hasNext()) {
     cur = iterMatch.next();
     deleteSecSession(Authorization, cur);
   }
 }
  public void updateSecSession(
      CFSecurityAuthorization Authorization, CFSecuritySecSessionBuff Buff) {
    CFSecuritySecSessionPKey pkey = schema.getFactorySecSession().newPKey();
    pkey.setRequiredSecSessionId(Buff.getRequiredSecSessionId());
    CFSecuritySecSessionBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newStaleCacheDetectedException(
              getClass(), "updateSecSession", "Existing record not found", "SecSession", pkey);
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "updateSecSession", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFSecuritySecSessionBySecUserIdxKey existingKeySecUserIdx =
        schema.getFactorySecSession().newSecUserIdxKey();
    existingKeySecUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId());

    CFSecuritySecSessionBySecUserIdxKey newKeySecUserIdx =
        schema.getFactorySecSession().newSecUserIdxKey();
    newKeySecUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId());

    CFSecuritySecSessionBySecDevIdxKey existingKeySecDevIdx =
        schema.getFactorySecSession().newSecDevIdxKey();
    existingKeySecDevIdx.setRequiredSecUserId(existing.getRequiredSecUserId());
    existingKeySecDevIdx.setOptionalSecDevName(existing.getOptionalSecDevName());

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

    CFSecuritySecSessionByStartIdxKey existingKeyStartIdx =
        schema.getFactorySecSession().newStartIdxKey();
    existingKeyStartIdx.setRequiredSecUserId(existing.getRequiredSecUserId());
    existingKeyStartIdx.setRequiredStart(existing.getRequiredStart());

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

    CFSecuritySecSessionByFinishIdxKey existingKeyFinishIdx =
        schema.getFactorySecSession().newFinishIdxKey();
    existingKeyFinishIdx.setRequiredSecUserId(existing.getRequiredSecUserId());
    existingKeyFinishIdx.setOptionalFinish(existing.getOptionalFinish());

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

    CFSecuritySecSessionBySecProxyIdxKey existingKeySecProxyIdx =
        schema.getFactorySecSession().newSecProxyIdxKey();
    existingKeySecProxyIdx.setOptionalSecProxyId(existing.getOptionalSecProxyId());

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

    // Check unique indexes

    if (!existingKeyStartIdx.equals(newKeyStartIdx)) {
      if (dictByStartIdx.containsKey(newKeyStartIdx)) {
        throw CFLib.getDefaultExceptionFactory()
            .newUniqueIndexViolationException(
                getClass(), "updateSecSession", "SessionStartIdx", newKeyStartIdx);
      }
    }

    // Validate foreign keys

    {
      boolean allNull = true;

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

    // Update is valid

    Map<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff> subdict;

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

    subdict = dictBySecUserIdx.get(existingKeySecUserIdx);
    if (subdict != null) {
      subdict.remove(pkey);
    }
    if (dictBySecUserIdx.containsKey(newKeySecUserIdx)) {
      subdict = dictBySecUserIdx.get(newKeySecUserIdx);
    } else {
      subdict = new HashMap<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff>();
      dictBySecUserIdx.put(newKeySecUserIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictBySecDevIdx.get(existingKeySecDevIdx);
    if (subdict != null) {
      subdict.remove(pkey);
    }
    if (dictBySecDevIdx.containsKey(newKeySecDevIdx)) {
      subdict = dictBySecDevIdx.get(newKeySecDevIdx);
    } else {
      subdict = new HashMap<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff>();
      dictBySecDevIdx.put(newKeySecDevIdx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByStartIdx.remove(existingKeyStartIdx);
    dictByStartIdx.put(newKeyStartIdx, Buff);

    subdict = dictByFinishIdx.get(existingKeyFinishIdx);
    if (subdict != null) {
      subdict.remove(pkey);
    }
    if (dictByFinishIdx.containsKey(newKeyFinishIdx)) {
      subdict = dictByFinishIdx.get(newKeyFinishIdx);
    } else {
      subdict = new HashMap<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff>();
      dictByFinishIdx.put(newKeyFinishIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictBySecProxyIdx.get(existingKeySecProxyIdx);
    if (subdict != null) {
      subdict.remove(pkey);
    }
    if (dictBySecProxyIdx.containsKey(newKeySecProxyIdx)) {
      subdict = dictBySecProxyIdx.get(newKeySecProxyIdx);
    } else {
      subdict = new HashMap<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff>();
      dictBySecProxyIdx.put(newKeySecProxyIdx, subdict);
    }
    subdict.put(pkey, Buff);
  }