public void forgetTSecGroupMemberByTenantIdx(long TenantId) {
    if (indexByTenantIdx == null) {
      return;
    }
    CFSecurityTSecGroupMemberByTenantIdxKey key =
        ((ICFBamSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newTenantIdxKey();
    key.setRequiredTenantId(TenantId);
    if (indexByTenantIdx.containsKey(key)) {
      Map<CFSecurityTSecGroupMemberPKey, ICFSecurityTSecGroupMemberObj> mapTenantIdx =
          indexByTenantIdx.get(key);
      if (mapTenantIdx != null) {
        List<ICFSecurityTSecGroupMemberObj> toForget =
            new LinkedList<ICFSecurityTSecGroupMemberObj>();
        ICFSecurityTSecGroupMemberObj cur = null;
        Iterator<ICFSecurityTSecGroupMemberObj> iter = mapTenantIdx.values().iterator();
        while (iter.hasNext()) {
          cur = iter.next();
          toForget.add(cur);
        }
        iter = toForget.iterator();
        while (iter.hasNext()) {
          cur = iter.next();
          cur.forget(true);
        }
      }

      indexByTenantIdx.remove(key);
    }
  }
  public void forgetTSecGroupMember(ICFSecurityTSecGroupMemberObj Obj, boolean forgetSubObjects) {
    ICFSecurityTSecGroupMemberObj obj = Obj;
    CFSecurityTSecGroupMemberPKey pkey = obj.getPKey();
    if (members.containsKey(pkey)) {
      ICFSecurityTSecGroupMemberObj keepObj = members.get(pkey);
      // Detach object from alternate, duplicate, all and PKey indexes

      if (indexByTenantIdx != null) {
        CFSecurityTSecGroupMemberByTenantIdxKey keyTenantIdx =
            ((ICFBamSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newTenantIdxKey();
        keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        Map<CFSecurityTSecGroupMemberPKey, ICFSecurityTSecGroupMemberObj> mapTenantIdx =
            indexByTenantIdx.get(keyTenantIdx);
        if (mapTenantIdx != null) {
          mapTenantIdx.remove(keepObj.getPKey());
        }
      }

      if (indexByGroupIdx != null) {
        CFSecurityTSecGroupMemberByGroupIdxKey keyGroupIdx =
            ((ICFBamSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newGroupIdxKey();
        keyGroupIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyGroupIdx.setRequiredTSecGroupId(keepObj.getRequiredTSecGroupId());
        Map<CFSecurityTSecGroupMemberPKey, ICFSecurityTSecGroupMemberObj> mapGroupIdx =
            indexByGroupIdx.get(keyGroupIdx);
        if (mapGroupIdx != null) {
          mapGroupIdx.remove(keepObj.getPKey());
        }
      }

      if (indexByUserIdx != null) {
        CFSecurityTSecGroupMemberByUserIdxKey keyUserIdx =
            ((ICFBamSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newUserIdxKey();
        keyUserIdx.setRequiredSecUserId(keepObj.getRequiredSecUserId());
        Map<CFSecurityTSecGroupMemberPKey, ICFSecurityTSecGroupMemberObj> mapUserIdx =
            indexByUserIdx.get(keyUserIdx);
        if (mapUserIdx != null) {
          mapUserIdx.remove(keepObj.getPKey());
        }
      }

      if (indexByUUserIdx != null) {
        CFSecurityTSecGroupMemberByUUserIdxKey keyUUserIdx =
            ((ICFBamSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newUUserIdxKey();
        keyUUserIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyUUserIdx.setRequiredTSecGroupId(keepObj.getRequiredTSecGroupId());
        keyUUserIdx.setRequiredSecUserId(keepObj.getRequiredSecUserId());
        indexByUUserIdx.remove(keyUUserIdx);
      }

      if (allTSecGroupMember != null) {
        allTSecGroupMember.remove(keepObj.getPKey());
      }
      members.remove(pkey);
      if (forgetSubObjects) {}
    }
  }
 public void deleteTSecGroupMemberByTenantIdx(long TenantId) {
   CFSecurityTSecGroupMemberByTenantIdxKey key =
       ((ICFBamSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newTenantIdxKey();
   key.setRequiredTenantId(TenantId);
   if (indexByTenantIdx == null) {
     indexByTenantIdx =
         new HashMap<
             CFSecurityTSecGroupMemberByTenantIdxKey,
             Map<CFSecurityTSecGroupMemberPKey, ICFSecurityTSecGroupMemberObj>>();
   }
   if (indexByTenantIdx.containsKey(key)) {
     Map<CFSecurityTSecGroupMemberPKey, ICFSecurityTSecGroupMemberObj> dict =
         indexByTenantIdx.get(key);
     ((ICFBamSchema) schema.getBackingStore())
         .getTableTSecGroupMember()
         .deleteTSecGroupMemberByTenantIdx(schema.getAuthorization(), TenantId);
     Iterator<ICFSecurityTSecGroupMemberObj> iter = dict.values().iterator();
     ICFSecurityTSecGroupMemberObj obj;
     List<ICFSecurityTSecGroupMemberObj> toForget =
         new LinkedList<ICFSecurityTSecGroupMemberObj>();
     while (iter.hasNext()) {
       obj = iter.next();
       toForget.add(obj);
     }
     iter = toForget.iterator();
     while (iter.hasNext()) {
       obj = iter.next();
       obj.forget(true);
     }
     indexByTenantIdx.remove(key);
   } else {
     ((ICFBamSchema) schema.getBackingStore())
         .getTableTSecGroupMember()
         .deleteTSecGroupMemberByTenantIdx(schema.getAuthorization(), TenantId);
   }
 }
 public List<ICFSecurityTSecGroupMemberObj> readTSecGroupMemberByTenantIdx(
     long TenantId, boolean forceRead) {
   final String S_ProcName = "readTSecGroupMemberByTenantIdx";
   CFSecurityTSecGroupMemberByTenantIdxKey key =
       ((ICFBamSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newTenantIdxKey();
   key.setRequiredTenantId(TenantId);
   Map<CFSecurityTSecGroupMemberPKey, ICFSecurityTSecGroupMemberObj> dict;
   if (indexByTenantIdx == null) {
     indexByTenantIdx =
         new HashMap<
             CFSecurityTSecGroupMemberByTenantIdxKey,
             Map<CFSecurityTSecGroupMemberPKey, ICFSecurityTSecGroupMemberObj>>();
   }
   if ((!forceRead) && indexByTenantIdx.containsKey(key)) {
     dict = indexByTenantIdx.get(key);
   } else {
     dict = new HashMap<CFSecurityTSecGroupMemberPKey, ICFSecurityTSecGroupMemberObj>();
     // Allow other threads to dirty-read while we're loading
     indexByTenantIdx.put(key, dict);
     ICFSecurityTSecGroupMemberObj obj;
     CFSecurityTSecGroupMemberBuff[] buffList =
         ((ICFBamSchema) schema.getBackingStore())
             .getTableTSecGroupMember()
             .readDerivedByTenantIdx(schema.getAuthorization(), TenantId);
     CFSecurityTSecGroupMemberBuff buff;
     for (int idx = 0; idx < buffList.length; idx++) {
       buff = buffList[idx];
       obj = schema.getTSecGroupMemberTableObj().newInstance();
       obj.setPKey(
           ((ICFBamSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newPKey());
       obj.setBuff(buff);
       ICFSecurityTSecGroupMemberObj realized = (ICFSecurityTSecGroupMemberObj) obj.realize();
     }
   }
   Comparator<ICFSecurityTSecGroupMemberObj> cmp =
       new Comparator<ICFSecurityTSecGroupMemberObj>() {
         public int compare(ICFSecurityTSecGroupMemberObj lhs, ICFSecurityTSecGroupMemberObj rhs) {
           if (lhs == null) {
             if (rhs == null) {
               return (0);
             } else {
               return (-1);
             }
           } else if (rhs == null) {
             return (1);
           } else {
             CFSecurityTSecGroupMemberPKey lhsPKey = lhs.getPKey();
             CFSecurityTSecGroupMemberPKey rhsPKey = rhs.getPKey();
             int ret = lhsPKey.compareTo(rhsPKey);
             return (ret);
           }
         }
       };
   int len = dict.size();
   ICFSecurityTSecGroupMemberObj arr[] = new ICFSecurityTSecGroupMemberObj[len];
   Iterator<ICFSecurityTSecGroupMemberObj> valIter = dict.values().iterator();
   int idx = 0;
   while ((idx < len) && valIter.hasNext()) {
     arr[idx++] = valIter.next();
   }
   if (idx < len) {
     throw CFLib.getDefaultExceptionFactory()
         .newArgumentUnderflowException(getClass(), S_ProcName, 0, "idx", idx, len);
   } else if (valIter.hasNext()) {
     throw CFLib.getDefaultExceptionFactory()
         .newArgumentOverflowException(getClass(), S_ProcName, 0, "idx", idx, len);
   }
   Arrays.sort(arr, cmp);
   ArrayList<ICFSecurityTSecGroupMemberObj> arrayList =
       new ArrayList<ICFSecurityTSecGroupMemberObj>(len);
   for (idx = 0; idx < len; idx++) {
     arrayList.add(arr[idx]);
   }
   List<ICFSecurityTSecGroupMemberObj> sortedList = arrayList;
   return (sortedList);
 }
  public ICFSecurityTSecGroupMemberObj realizeTSecGroupMember(ICFSecurityTSecGroupMemberObj Obj) {
    ICFSecurityTSecGroupMemberObj obj = Obj;
    CFSecurityTSecGroupMemberPKey pkey = obj.getPKey();
    ICFSecurityTSecGroupMemberObj keepObj = null;
    if (members.containsKey(pkey) && (null != members.get(pkey))) {
      ICFSecurityTSecGroupMemberObj 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) {
        CFSecurityTSecGroupMemberByTenantIdxKey keyTenantIdx =
            ((ICFBamSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newTenantIdxKey();
        keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        Map<CFSecurityTSecGroupMemberPKey, ICFSecurityTSecGroupMemberObj> mapTenantIdx =
            indexByTenantIdx.get(keyTenantIdx);
        if (mapTenantIdx != null) {
          mapTenantIdx.remove(keepObj.getPKey());
        }
      }

      if (indexByGroupIdx != null) {
        CFSecurityTSecGroupMemberByGroupIdxKey keyGroupIdx =
            ((ICFBamSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newGroupIdxKey();
        keyGroupIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyGroupIdx.setRequiredTSecGroupId(keepObj.getRequiredTSecGroupId());
        Map<CFSecurityTSecGroupMemberPKey, ICFSecurityTSecGroupMemberObj> mapGroupIdx =
            indexByGroupIdx.get(keyGroupIdx);
        if (mapGroupIdx != null) {
          mapGroupIdx.remove(keepObj.getPKey());
        }
      }

      if (indexByUserIdx != null) {
        CFSecurityTSecGroupMemberByUserIdxKey keyUserIdx =
            ((ICFBamSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newUserIdxKey();
        keyUserIdx.setRequiredSecUserId(keepObj.getRequiredSecUserId());
        Map<CFSecurityTSecGroupMemberPKey, ICFSecurityTSecGroupMemberObj> mapUserIdx =
            indexByUserIdx.get(keyUserIdx);
        if (mapUserIdx != null) {
          mapUserIdx.remove(keepObj.getPKey());
        }
      }

      if (indexByUUserIdx != null) {
        CFSecurityTSecGroupMemberByUUserIdxKey keyUUserIdx =
            ((ICFBamSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newUUserIdxKey();
        keyUUserIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyUUserIdx.setRequiredTSecGroupId(keepObj.getRequiredTSecGroupId());
        keyUUserIdx.setRequiredSecUserId(keepObj.getRequiredSecUserId());
        indexByUUserIdx.remove(keyUUserIdx);
      }

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

      if (indexByTenantIdx != null) {
        CFSecurityTSecGroupMemberByTenantIdxKey keyTenantIdx =
            ((ICFBamSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newTenantIdxKey();
        keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        Map<CFSecurityTSecGroupMemberPKey, ICFSecurityTSecGroupMemberObj> mapTenantIdx =
            indexByTenantIdx.get(keyTenantIdx);
        if (mapTenantIdx != null) {
          mapTenantIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByGroupIdx != null) {
        CFSecurityTSecGroupMemberByGroupIdxKey keyGroupIdx =
            ((ICFBamSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newGroupIdxKey();
        keyGroupIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyGroupIdx.setRequiredTSecGroupId(keepObj.getRequiredTSecGroupId());
        Map<CFSecurityTSecGroupMemberPKey, ICFSecurityTSecGroupMemberObj> mapGroupIdx =
            indexByGroupIdx.get(keyGroupIdx);
        if (mapGroupIdx != null) {
          mapGroupIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByUserIdx != null) {
        CFSecurityTSecGroupMemberByUserIdxKey keyUserIdx =
            ((ICFBamSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newUserIdxKey();
        keyUserIdx.setRequiredSecUserId(keepObj.getRequiredSecUserId());
        Map<CFSecurityTSecGroupMemberPKey, ICFSecurityTSecGroupMemberObj> mapUserIdx =
            indexByUserIdx.get(keyUserIdx);
        if (mapUserIdx != null) {
          mapUserIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByUUserIdx != null) {
        CFSecurityTSecGroupMemberByUUserIdxKey keyUUserIdx =
            ((ICFBamSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newUUserIdxKey();
        keyUUserIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyUUserIdx.setRequiredTSecGroupId(keepObj.getRequiredTSecGroupId());
        keyUUserIdx.setRequiredSecUserId(keepObj.getRequiredSecUserId());
        indexByUUserIdx.put(keyUUserIdx, keepObj);
      }
      if (allTSecGroupMember != null) {
        allTSecGroupMember.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 (allTSecGroupMember != null) {
        allTSecGroupMember.put(keepObj.getPKey(), keepObj);
      }

      if (indexByTenantIdx != null) {
        CFSecurityTSecGroupMemberByTenantIdxKey keyTenantIdx =
            ((ICFBamSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newTenantIdxKey();
        keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        Map<CFSecurityTSecGroupMemberPKey, ICFSecurityTSecGroupMemberObj> mapTenantIdx =
            indexByTenantIdx.get(keyTenantIdx);
        if (mapTenantIdx != null) {
          mapTenantIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByGroupIdx != null) {
        CFSecurityTSecGroupMemberByGroupIdxKey keyGroupIdx =
            ((ICFBamSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newGroupIdxKey();
        keyGroupIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyGroupIdx.setRequiredTSecGroupId(keepObj.getRequiredTSecGroupId());
        Map<CFSecurityTSecGroupMemberPKey, ICFSecurityTSecGroupMemberObj> mapGroupIdx =
            indexByGroupIdx.get(keyGroupIdx);
        if (mapGroupIdx != null) {
          mapGroupIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByUserIdx != null) {
        CFSecurityTSecGroupMemberByUserIdxKey keyUserIdx =
            ((ICFBamSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newUserIdxKey();
        keyUserIdx.setRequiredSecUserId(keepObj.getRequiredSecUserId());
        Map<CFSecurityTSecGroupMemberPKey, ICFSecurityTSecGroupMemberObj> mapUserIdx =
            indexByUserIdx.get(keyUserIdx);
        if (mapUserIdx != null) {
          mapUserIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByUUserIdx != null) {
        CFSecurityTSecGroupMemberByUUserIdxKey keyUUserIdx =
            ((ICFBamSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newUUserIdxKey();
        keyUUserIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyUUserIdx.setRequiredTSecGroupId(keepObj.getRequiredTSecGroupId());
        keyUUserIdx.setRequiredSecUserId(keepObj.getRequiredSecUserId());
        indexByUUserIdx.put(keyUUserIdx, keepObj);
      }
    }
    return (keepObj);
  }