public ICFSecuritySecGroupObj readSecGroupByUNameIdx(
     long ClusterId, String Name, boolean forceRead) {
   if (indexByUNameIdx == null) {
     indexByUNameIdx = new HashMap<CFSecuritySecGroupByUNameIdxKey, ICFSecuritySecGroupObj>();
   }
   CFSecuritySecGroupByUNameIdxKey key =
       ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecGroup().newUNameIdxKey();
   key.setRequiredClusterId(ClusterId);
   key.setRequiredName(Name);
   ICFSecuritySecGroupObj obj = null;
   if ((!forceRead) && indexByUNameIdx.containsKey(key)) {
     obj = indexByUNameIdx.get(key);
   } else {
     CFSecuritySecGroupBuff buff =
         ((ICFSecuritySchema) schema.getBackingStore())
             .getTableSecGroup()
             .readDerivedByUNameIdx(schema.getAuthorization(), ClusterId, Name);
     if (buff != null) {
       obj = schema.getSecGroupTableObj().newInstance();
       obj.setPKey(((ICFSecuritySchema) schema.getBackingStore()).getFactorySecGroup().newPKey());
       obj.setBuff(buff);
       obj = (ICFSecuritySecGroupObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       indexByUNameIdx.put(key, null);
     }
   }
   return (obj);
 }
 public ICFSecuritySecGroupObj lockSecGroup(CFSecuritySecGroupPKey pkey) {
   ICFSecuritySecGroupObj locked = null;
   CFSecuritySecGroupBuff lockBuff =
       ((ICFSecuritySchema) schema.getBackingStore())
           .getTableSecGroup()
           .lockDerived(schema.getAuthorization(), pkey);
   if (lockBuff != null) {
     locked = schema.getSecGroupTableObj().newInstance();
     locked.setPKey(((ICFSecuritySchema) schema.getBackingStore()).getFactorySecGroup().newPKey());
     locked.setBuff(lockBuff);
     locked = (ICFSecuritySecGroupObj) locked.realize();
   } else {
     throw CFLib.getDefaultExceptionFactory()
         .newCollisionDetectedException(getClass(), "lockSecGroup", pkey);
   }
   return (locked);
 }
 public ICFSecuritySecGroupObj readSecGroup(CFSecuritySecGroupPKey pkey, boolean forceRead) {
   ICFSecuritySecGroupObj obj = null;
   if ((!forceRead) && members.containsKey(pkey)) {
     obj = members.get(pkey);
   } else {
     CFSecuritySecGroupBuff readBuff =
         ((ICFSecuritySchema) schema.getBackingStore())
             .getTableSecGroup()
             .readDerivedByIdIdx(
                 schema.getAuthorization(),
                 pkey.getRequiredClusterId(),
                 pkey.getRequiredSecGroupId());
     if (readBuff != null) {
       obj = schema.getSecGroupTableObj().newInstance();
       obj.setPKey(((ICFSecuritySchema) schema.getBackingStore()).getFactorySecGroup().newPKey());
       obj.setBuff(readBuff);
       obj = (ICFSecuritySecGroupObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       members.put(pkey, null);
     }
   }
   return (obj);
 }
 public List<ICFSecuritySecGroupObj> readSecGroupByClusterIdx(long ClusterId, boolean forceRead) {
   final String S_ProcName = "readSecGroupByClusterIdx";
   CFSecuritySecGroupByClusterIdxKey key =
       ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecGroup().newClusterIdxKey();
   key.setRequiredClusterId(ClusterId);
   Map<CFSecuritySecGroupPKey, ICFSecuritySecGroupObj> dict;
   if (indexByClusterIdx == null) {
     indexByClusterIdx =
         new HashMap<
             CFSecuritySecGroupByClusterIdxKey,
             Map<CFSecuritySecGroupPKey, ICFSecuritySecGroupObj>>();
   }
   if ((!forceRead) && indexByClusterIdx.containsKey(key)) {
     dict = indexByClusterIdx.get(key);
   } else {
     dict = new HashMap<CFSecuritySecGroupPKey, ICFSecuritySecGroupObj>();
     // Allow other threads to dirty-read while we're loading
     indexByClusterIdx.put(key, dict);
     ICFSecuritySecGroupObj obj;
     CFSecuritySecGroupBuff[] buffList =
         ((ICFSecuritySchema) schema.getBackingStore())
             .getTableSecGroup()
             .readDerivedByClusterIdx(schema.getAuthorization(), ClusterId);
     CFSecuritySecGroupBuff buff;
     for (int idx = 0; idx < buffList.length; idx++) {
       buff = buffList[idx];
       obj = schema.getSecGroupTableObj().newInstance();
       obj.setPKey(((ICFSecuritySchema) schema.getBackingStore()).getFactorySecGroup().newPKey());
       obj.setBuff(buff);
       ICFSecuritySecGroupObj realized = (ICFSecuritySecGroupObj) obj.realize();
     }
   }
   Comparator<ICFSecuritySecGroupObj> cmp =
       new Comparator<ICFSecuritySecGroupObj>() {
         public int compare(ICFSecuritySecGroupObj lhs, ICFSecuritySecGroupObj rhs) {
           if (lhs == null) {
             if (rhs == null) {
               return (0);
             } else {
               return (-1);
             }
           } else if (rhs == null) {
             return (1);
           } else {
             CFSecuritySecGroupPKey lhsPKey = lhs.getPKey();
             CFSecuritySecGroupPKey rhsPKey = rhs.getPKey();
             int ret = lhsPKey.compareTo(rhsPKey);
             return (ret);
           }
         }
       };
   int len = dict.size();
   ICFSecuritySecGroupObj arr[] = new ICFSecuritySecGroupObj[len];
   Iterator<ICFSecuritySecGroupObj> 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<ICFSecuritySecGroupObj> arrayList = new ArrayList<ICFSecuritySecGroupObj>(len);
   for (idx = 0; idx < len; idx++) {
     arrayList.add(arr[idx]);
   }
   List<ICFSecuritySecGroupObj> sortedList = arrayList;
   return (sortedList);
 }
 public List<ICFSecuritySecGroupObj> readAllSecGroup(boolean forceRead) {
   final String S_ProcName = "readAllSecGroup";
   if ((allSecGroup == null) || forceRead) {
     Map<CFSecuritySecGroupPKey, ICFSecuritySecGroupObj> map =
         new HashMap<CFSecuritySecGroupPKey, ICFSecuritySecGroupObj>();
     allSecGroup = map;
     CFSecuritySecGroupBuff[] buffList =
         ((ICFSecuritySchema) schema.getBackingStore())
             .getTableSecGroup()
             .readAllDerived(schema.getAuthorization());
     CFSecuritySecGroupBuff buff;
     ICFSecuritySecGroupObj obj;
     for (int idx = 0; idx < buffList.length; idx++) {
       buff = buffList[idx];
       obj = newInstance();
       obj.setPKey(((ICFSecuritySchema) schema.getBackingStore()).getFactorySecGroup().newPKey());
       obj.setBuff(buff);
       ICFSecuritySecGroupObj realized = (ICFSecuritySecGroupObj) obj.realize();
     }
   }
   Comparator<ICFSecuritySecGroupObj> cmp =
       new Comparator<ICFSecuritySecGroupObj>() {
         public int compare(ICFSecuritySecGroupObj lhs, ICFSecuritySecGroupObj rhs) {
           if (lhs == null) {
             if (rhs == null) {
               return (0);
             } else {
               return (-1);
             }
           } else if (rhs == null) {
             return (1);
           } else {
             CFSecuritySecGroupPKey lhsPKey = lhs.getPKey();
             CFSecuritySecGroupPKey rhsPKey = rhs.getPKey();
             int ret = lhsPKey.compareTo(rhsPKey);
             return (ret);
           }
         }
       };
   int len = allSecGroup.size();
   ICFSecuritySecGroupObj arr[] = new ICFSecuritySecGroupObj[len];
   Iterator<ICFSecuritySecGroupObj> valIter = allSecGroup.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<ICFSecuritySecGroupObj> arrayList = new ArrayList<ICFSecuritySecGroupObj>(len);
   for (idx = 0; idx < len; idx++) {
     arrayList.add(arr[idx]);
   }
   List<ICFSecuritySecGroupObj> sortedList = arrayList;
   return (sortedList);
 }
  public ICFSecuritySecGroupObj realizeSecGroup(ICFSecuritySecGroupObj Obj) {
    ICFSecuritySecGroupObj obj = Obj;
    CFSecuritySecGroupPKey pkey = obj.getPKey();
    ICFSecuritySecGroupObj keepObj = null;
    if (members.containsKey(pkey) && (null != members.get(pkey))) {
      ICFSecuritySecGroupObj 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 (indexByClusterIdx != null) {
        CFSecuritySecGroupByClusterIdxKey keyClusterIdx =
            ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecGroup().newClusterIdxKey();
        keyClusterIdx.setRequiredClusterId(keepObj.getRequiredClusterId());
        Map<CFSecuritySecGroupPKey, ICFSecuritySecGroupObj> mapClusterIdx =
            indexByClusterIdx.get(keyClusterIdx);
        if (mapClusterIdx != null) {
          mapClusterIdx.remove(keepObj.getPKey());
        }
      }

      if (indexByUNameIdx != null) {
        CFSecuritySecGroupByUNameIdxKey keyUNameIdx =
            ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecGroup().newUNameIdxKey();
        keyUNameIdx.setRequiredClusterId(keepObj.getRequiredClusterId());
        keyUNameIdx.setRequiredName(keepObj.getRequiredName());
        indexByUNameIdx.remove(keyUNameIdx);
      }

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

      if (indexByClusterIdx != null) {
        CFSecuritySecGroupByClusterIdxKey keyClusterIdx =
            ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecGroup().newClusterIdxKey();
        keyClusterIdx.setRequiredClusterId(keepObj.getRequiredClusterId());
        Map<CFSecuritySecGroupPKey, ICFSecuritySecGroupObj> mapClusterIdx =
            indexByClusterIdx.get(keyClusterIdx);
        if (mapClusterIdx != null) {
          mapClusterIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByUNameIdx != null) {
        CFSecuritySecGroupByUNameIdxKey keyUNameIdx =
            ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecGroup().newUNameIdxKey();
        keyUNameIdx.setRequiredClusterId(keepObj.getRequiredClusterId());
        keyUNameIdx.setRequiredName(keepObj.getRequiredName());
        indexByUNameIdx.put(keyUNameIdx, keepObj);
      }
      if (allSecGroup != null) {
        allSecGroup.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 (allSecGroup != null) {
        allSecGroup.put(keepObj.getPKey(), keepObj);
      }

      if (indexByClusterIdx != null) {
        CFSecuritySecGroupByClusterIdxKey keyClusterIdx =
            ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecGroup().newClusterIdxKey();
        keyClusterIdx.setRequiredClusterId(keepObj.getRequiredClusterId());
        Map<CFSecuritySecGroupPKey, ICFSecuritySecGroupObj> mapClusterIdx =
            indexByClusterIdx.get(keyClusterIdx);
        if (mapClusterIdx != null) {
          mapClusterIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByUNameIdx != null) {
        CFSecuritySecGroupByUNameIdxKey keyUNameIdx =
            ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecGroup().newUNameIdxKey();
        keyUNameIdx.setRequiredClusterId(keepObj.getRequiredClusterId());
        keyUNameIdx.setRequiredName(keepObj.getRequiredName());
        indexByUNameIdx.put(keyUNameIdx, keepObj);
      }
    }
    return (keepObj);
  }