public CFSecurityServiceBuff lockDerived(
     CFSecurityAuthorization Authorization, CFSecurityServicePKey PKey) {
   final String S_ProcName = "CFBamRamService.readDerived";
   CFSecurityServicePKey key = schema.getFactoryService().newPKey();
   key.setRequiredClusterId(PKey.getRequiredClusterId());
   key.setRequiredServiceId(PKey.getRequiredServiceId());
   CFSecurityServiceBuff buff;
   if (dictByPKey.containsKey(key)) {
     buff = dictByPKey.get(key);
   } else {
     buff = null;
   }
   return (buff);
 }
  public int compareTo(Object obj) {
    if (obj == null) {
      return (-1);
    } else if (obj instanceof CFSecurityServiceBuff) {
      CFSecurityServiceBuff rhs = (CFSecurityServiceBuff) obj;
      int retval = 0;
      {
        int cmp = getCreatedByUserId().compareTo(rhs.getCreatedByUserId());
        if (cmp != 0) {
          return (cmp);
        }

        cmp = getCreatedAt().compareTo(rhs.getCreatedAt());
        if (cmp != 0) {
          return (cmp);
        }

        cmp = getUpdatedByUserId().compareTo(rhs.getUpdatedByUserId());
        if (cmp != 0) {
          return (cmp);
        }

        cmp = getUpdatedAt().compareTo(rhs.getUpdatedAt());
        if (cmp != 0) {
          return (cmp);
        }
      }
      if (getRequiredClusterId() < rhs.getRequiredClusterId()) {
        return (-1);
      } else if (getRequiredClusterId() > rhs.getRequiredClusterId()) {
        return (1);
      }
      if (getRequiredServiceId() < rhs.getRequiredServiceId()) {
        return (-1);
      } else if (getRequiredServiceId() > rhs.getRequiredServiceId()) {
        return (1);
      }
      if (getRequiredHostNodeId() < rhs.getRequiredHostNodeId()) {
        return (-1);
      } else if (getRequiredHostNodeId() > rhs.getRequiredHostNodeId()) {
        return (1);
      }
      if (getRequiredServiceTypeId() < rhs.getRequiredServiceTypeId()) {
        return (-1);
      } else if (getRequiredServiceTypeId() > rhs.getRequiredServiceTypeId()) {
        return (1);
      }
      if (getRequiredHostPort() < rhs.getRequiredHostPort()) {
        return (-1);
      } else if (getRequiredHostPort() > rhs.getRequiredHostPort()) {
        return (1);
      }
      return (0);
    } else if (obj instanceof CFSecurityServicePKey) {
      CFSecurityServicePKey rhs = (CFSecurityServicePKey) obj;
      if (getRequiredClusterId() < rhs.getRequiredClusterId()) {
        return (-1);
      } else if (getRequiredClusterId() > rhs.getRequiredClusterId()) {
        return (1);
      }
      if (getRequiredServiceId() < rhs.getRequiredServiceId()) {
        return (-1);
      } else if (getRequiredServiceId() > rhs.getRequiredServiceId()) {
        return (1);
      }
      return (0);
    } else if (obj instanceof CFSecurityServiceHPKey) {
      CFSecurityServiceHPKey rhs = (CFSecurityServiceHPKey) obj;
      {
        int lhsRequiredRevision = getRequiredRevision();
        int rhsRequiredRevision = rhs.getRequiredRevision();
        if (lhsRequiredRevision < rhsRequiredRevision) {
          return (-1);
        } else if (lhsRequiredRevision > rhsRequiredRevision) {
          return (1);
        }
      }
      if (getRequiredClusterId() < rhs.getRequiredClusterId()) {
        return (-1);
      } else if (getRequiredClusterId() > rhs.getRequiredClusterId()) {
        return (1);
      }
      if (getRequiredServiceId() < rhs.getRequiredServiceId()) {
        return (-1);
      } else if (getRequiredServiceId() > rhs.getRequiredServiceId()) {
        return (1);
      }
      return (0);
    } else if (obj instanceof CFSecurityServiceHBuff) {
      CFSecurityServiceHBuff rhs = (CFSecurityServiceHBuff) obj;
      int retval = 0;
      if (getRequiredClusterId() < rhs.getRequiredClusterId()) {
        return (-1);
      } else if (getRequiredClusterId() > rhs.getRequiredClusterId()) {
        return (1);
      }
      if (getRequiredServiceId() < rhs.getRequiredServiceId()) {
        return (-1);
      } else if (getRequiredServiceId() > rhs.getRequiredServiceId()) {
        return (1);
      }
      if (getRequiredHostNodeId() < rhs.getRequiredHostNodeId()) {
        return (-1);
      } else if (getRequiredHostNodeId() > rhs.getRequiredHostNodeId()) {
        return (1);
      }
      if (getRequiredServiceTypeId() < rhs.getRequiredServiceTypeId()) {
        return (-1);
      } else if (getRequiredServiceTypeId() > rhs.getRequiredServiceTypeId()) {
        return (1);
      }
      if (getRequiredHostPort() < rhs.getRequiredHostPort()) {
        return (-1);
      } else if (getRequiredHostPort() > rhs.getRequiredHostPort()) {
        return (1);
      }
      return (0);
    } else if (obj instanceof CFSecurityServiceByClusterIdxKey) {
      CFSecurityServiceByClusterIdxKey rhs = (CFSecurityServiceByClusterIdxKey) obj;

      if (getRequiredClusterId() < rhs.getRequiredClusterId()) {
        return (-1);
      } else if (getRequiredClusterId() > rhs.getRequiredClusterId()) {
        return (1);
      }
      return (0);
    } else if (obj instanceof CFSecurityServiceByHostIdxKey) {
      CFSecurityServiceByHostIdxKey rhs = (CFSecurityServiceByHostIdxKey) obj;

      if (getRequiredClusterId() < rhs.getRequiredClusterId()) {
        return (-1);
      } else if (getRequiredClusterId() > rhs.getRequiredClusterId()) {
        return (1);
      }
      if (getRequiredHostNodeId() < rhs.getRequiredHostNodeId()) {
        return (-1);
      } else if (getRequiredHostNodeId() > rhs.getRequiredHostNodeId()) {
        return (1);
      }
      return (0);
    } else if (obj instanceof CFSecurityServiceByTypeIdxKey) {
      CFSecurityServiceByTypeIdxKey rhs = (CFSecurityServiceByTypeIdxKey) obj;

      if (getRequiredServiceTypeId() < rhs.getRequiredServiceTypeId()) {
        return (-1);
      } else if (getRequiredServiceTypeId() > rhs.getRequiredServiceTypeId()) {
        return (1);
      }
      return (0);
    } else if (obj instanceof CFSecurityServiceByUTypeIdxKey) {
      CFSecurityServiceByUTypeIdxKey rhs = (CFSecurityServiceByUTypeIdxKey) obj;

      if (getRequiredClusterId() < rhs.getRequiredClusterId()) {
        return (-1);
      } else if (getRequiredClusterId() > rhs.getRequiredClusterId()) {
        return (1);
      }
      if (getRequiredHostNodeId() < rhs.getRequiredHostNodeId()) {
        return (-1);
      } else if (getRequiredHostNodeId() > rhs.getRequiredHostNodeId()) {
        return (1);
      }
      if (getRequiredServiceTypeId() < rhs.getRequiredServiceTypeId()) {
        return (-1);
      } else if (getRequiredServiceTypeId() > rhs.getRequiredServiceTypeId()) {
        return (1);
      }
      return (0);
    } else if (obj instanceof CFSecurityServiceByUHostPortIdxKey) {
      CFSecurityServiceByUHostPortIdxKey rhs = (CFSecurityServiceByUHostPortIdxKey) obj;

      if (getRequiredClusterId() < rhs.getRequiredClusterId()) {
        return (-1);
      } else if (getRequiredClusterId() > rhs.getRequiredClusterId()) {
        return (1);
      }
      if (getRequiredHostNodeId() < rhs.getRequiredHostNodeId()) {
        return (-1);
      } else if (getRequiredHostNodeId() > rhs.getRequiredHostNodeId()) {
        return (1);
      }
      if (getRequiredHostPort() < rhs.getRequiredHostPort()) {
        return (-1);
      } else if (getRequiredHostPort() > rhs.getRequiredHostPort()) {
        return (1);
      }
      return (0);
    } else {
      throw CFLib.getDefaultExceptionFactory()
          .newUnsupportedClassException(getClass(), "compareTo", "obj", obj, null);
    }
  }
 public boolean equals(Object obj) {
   if (obj == null) {
     return (false);
   } else if (obj instanceof CFSecurityServiceBuff) {
     CFSecurityServiceBuff rhs = (CFSecurityServiceBuff) obj;
     if (!getCreatedByUserId().equals(rhs.getCreatedByUserId())) {
       return (false);
     }
     if (!getCreatedAt().equals(rhs.getCreatedAt())) {
       return (false);
     }
     if (!getUpdatedByUserId().equals(rhs.getUpdatedByUserId())) {
       return (false);
     }
     if (!getUpdatedAt().equals(rhs.getUpdatedAt())) {
       return (false);
     }
     if (getRequiredClusterId() != rhs.getRequiredClusterId()) {
       return (false);
     }
     if (getRequiredServiceId() != rhs.getRequiredServiceId()) {
       return (false);
     }
     if (getRequiredHostNodeId() != rhs.getRequiredHostNodeId()) {
       return (false);
     }
     if (getRequiredServiceTypeId() != rhs.getRequiredServiceTypeId()) {
       return (false);
     }
     if (getRequiredHostPort() != rhs.getRequiredHostPort()) {
       return (false);
     }
     return (true);
   } else if (obj instanceof CFSecurityServicePKey) {
     CFSecurityServicePKey rhs = (CFSecurityServicePKey) obj;
     if (getRequiredClusterId() != rhs.getRequiredClusterId()) {
       return (false);
     }
     if (getRequiredServiceId() != rhs.getRequiredServiceId()) {
       return (false);
     }
     return (true);
   } else if (obj instanceof CFSecurityServiceHBuff) {
     CFSecurityServiceHBuff rhs = (CFSecurityServiceHBuff) obj;
     if (getRequiredClusterId() != rhs.getRequiredClusterId()) {
       return (false);
     }
     if (getRequiredServiceId() != rhs.getRequiredServiceId()) {
       return (false);
     }
     if (getRequiredHostNodeId() != rhs.getRequiredHostNodeId()) {
       return (false);
     }
     if (getRequiredServiceTypeId() != rhs.getRequiredServiceTypeId()) {
       return (false);
     }
     if (getRequiredHostPort() != rhs.getRequiredHostPort()) {
       return (false);
     }
     return (true);
   } else if (obj instanceof CFSecurityServiceHPKey) {
     CFSecurityServiceHPKey rhs = (CFSecurityServiceHPKey) obj;
     if (getRequiredClusterId() != rhs.getRequiredClusterId()) {
       return (false);
     }
     if (getRequiredServiceId() != rhs.getRequiredServiceId()) {
       return (false);
     }
     return (true);
   } else if (obj instanceof CFSecurityServiceByClusterIdxKey) {
     CFSecurityServiceByClusterIdxKey rhs = (CFSecurityServiceByClusterIdxKey) obj;
     if (getRequiredClusterId() != rhs.getRequiredClusterId()) {
       return (false);
     }
     return (true);
   } else if (obj instanceof CFSecurityServiceByHostIdxKey) {
     CFSecurityServiceByHostIdxKey rhs = (CFSecurityServiceByHostIdxKey) obj;
     if (getRequiredClusterId() != rhs.getRequiredClusterId()) {
       return (false);
     }
     if (getRequiredHostNodeId() != rhs.getRequiredHostNodeId()) {
       return (false);
     }
     return (true);
   } else if (obj instanceof CFSecurityServiceByTypeIdxKey) {
     CFSecurityServiceByTypeIdxKey rhs = (CFSecurityServiceByTypeIdxKey) obj;
     if (getRequiredServiceTypeId() != rhs.getRequiredServiceTypeId()) {
       return (false);
     }
     return (true);
   } else if (obj instanceof CFSecurityServiceByUTypeIdxKey) {
     CFSecurityServiceByUTypeIdxKey rhs = (CFSecurityServiceByUTypeIdxKey) obj;
     if (getRequiredClusterId() != rhs.getRequiredClusterId()) {
       return (false);
     }
     if (getRequiredHostNodeId() != rhs.getRequiredHostNodeId()) {
       return (false);
     }
     if (getRequiredServiceTypeId() != rhs.getRequiredServiceTypeId()) {
       return (false);
     }
     return (true);
   } else if (obj instanceof CFSecurityServiceByUHostPortIdxKey) {
     CFSecurityServiceByUHostPortIdxKey rhs = (CFSecurityServiceByUHostPortIdxKey) obj;
     if (getRequiredClusterId() != rhs.getRequiredClusterId()) {
       return (false);
     }
     if (getRequiredHostNodeId() != rhs.getRequiredHostNodeId()) {
       return (false);
     }
     if (getRequiredHostPort() != rhs.getRequiredHostPort()) {
       return (false);
     }
     return (true);
   } else {
     boolean retval = super.equals(obj);
     return (retval);
   }
 }
  public void createService(CFSecurityAuthorization Authorization, CFSecurityServiceBuff Buff) {
    final String S_ProcName = "createService";
    CFSecurityServicePKey pkey = schema.getFactoryService().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredServiceId(
        ((CFBamRamClusterTable) schema.getTableCluster())
            .nextServiceIdGen(Authorization, Buff.getRequiredClusterId()));
    Buff.setRequiredClusterId(pkey.getRequiredClusterId());
    Buff.setRequiredServiceId(pkey.getRequiredServiceId());
    CFSecurityServiceByClusterIdxKey keyClusterIdx = schema.getFactoryService().newClusterIdxKey();
    keyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

    CFSecurityServiceByHostIdxKey keyHostIdx = schema.getFactoryService().newHostIdxKey();
    keyHostIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    keyHostIdx.setRequiredHostNodeId(Buff.getRequiredHostNodeId());

    CFSecurityServiceByTypeIdxKey keyTypeIdx = schema.getFactoryService().newTypeIdxKey();
    keyTypeIdx.setRequiredServiceTypeId(Buff.getRequiredServiceTypeId());

    CFSecurityServiceByUTypeIdxKey keyUTypeIdx = schema.getFactoryService().newUTypeIdxKey();
    keyUTypeIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    keyUTypeIdx.setRequiredHostNodeId(Buff.getRequiredHostNodeId());
    keyUTypeIdx.setRequiredServiceTypeId(Buff.getRequiredServiceTypeId());

    CFSecurityServiceByUHostPortIdxKey keyUHostPortIdx =
        schema.getFactoryService().newUHostPortIdxKey();
    keyUHostPortIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    keyUHostPortIdx.setRequiredHostNodeId(Buff.getRequiredHostNodeId());
    keyUHostPortIdx.setRequiredHostPort(Buff.getRequiredHostPort());

    // Validate unique indexes

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

    if (dictByUTypeIdx.containsKey(keyUTypeIdx)) {
      throw CFLib.getDefaultExceptionFactory()
          .newUniqueIndexViolationException(getClass(), S_ProcName, "ServiceUTypeIdx", keyUTypeIdx);
    }

    if (dictByUHostPortIdx.containsKey(keyUHostPortIdx)) {
      throw CFLib.getDefaultExceptionFactory()
          .newUniqueIndexViolationException(
              getClass(), S_ProcName, "ServiceUHostPort", keyUHostPortIdx);
    }

    // Validate foreign keys

    {
      boolean allNull = true;
      allNull = false;
      if (!allNull) {
        if (null
            == schema
                .getTableCluster()
                .readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), S_ProcName, "Owner", "ServiceCluster", "Cluster", null);
        }
      }
    }

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    Map<CFSecurityServicePKey, CFSecurityServiceBuff> subdictClusterIdx;
    if (dictByClusterIdx.containsKey(keyClusterIdx)) {
      subdictClusterIdx = dictByClusterIdx.get(keyClusterIdx);
    } else {
      subdictClusterIdx = new HashMap<CFSecurityServicePKey, CFSecurityServiceBuff>();
      dictByClusterIdx.put(keyClusterIdx, subdictClusterIdx);
    }
    subdictClusterIdx.put(pkey, Buff);

    Map<CFSecurityServicePKey, CFSecurityServiceBuff> subdictHostIdx;
    if (dictByHostIdx.containsKey(keyHostIdx)) {
      subdictHostIdx = dictByHostIdx.get(keyHostIdx);
    } else {
      subdictHostIdx = new HashMap<CFSecurityServicePKey, CFSecurityServiceBuff>();
      dictByHostIdx.put(keyHostIdx, subdictHostIdx);
    }
    subdictHostIdx.put(pkey, Buff);

    Map<CFSecurityServicePKey, CFSecurityServiceBuff> subdictTypeIdx;
    if (dictByTypeIdx.containsKey(keyTypeIdx)) {
      subdictTypeIdx = dictByTypeIdx.get(keyTypeIdx);
    } else {
      subdictTypeIdx = new HashMap<CFSecurityServicePKey, CFSecurityServiceBuff>();
      dictByTypeIdx.put(keyTypeIdx, subdictTypeIdx);
    }
    subdictTypeIdx.put(pkey, Buff);

    dictByUTypeIdx.put(keyUTypeIdx, Buff);

    dictByUHostPortIdx.put(keyUHostPortIdx, Buff);
  }