public CFSecuritySecFormBuff lockBuff(
     CFSecurityAuthorization Authorization, CFSecuritySecFormPKey PKey) {
   final String S_ProcName = "lockBuff";
   if (!schema.isTransactionOpen()) {
     throw CFLib.getDefaultExceptionFactory()
         .newUsageException(getClass(), S_ProcName, "Transaction not open");
   }
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     long ClusterId = PKey.getRequiredClusterId();
     int SecFormId = PKey.getRequiredSecFormId();
     String sql = "exec sp_lock_secform ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?";
     if (stmtLockBuffByPKey == null) {
       stmtLockBuffByPKey = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtLockBuffByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtLockBuffByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtLockBuffByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtLockBuffByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtLockBuffByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtLockBuffByPKey.setLong(argIdx++, ClusterId);
     stmtLockBuffByPKey.setInt(argIdx++, SecFormId);
     resultSet = stmtLockBuffByPKey.executeQuery();
     if (resultSet.next()) {
       CFSecuritySecFormBuff buff = unpackSecFormResultSetToBuff(resultSet);
       if (resultSet.next()) {
         resultSet.last();
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(
                 getClass(),
                 S_ProcName,
                 "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
       }
       return (buff);
     } else {
       return (null);
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
 public void deleteSecFormBySecAppIdx(
     CFSecurityAuthorization Authorization, long ClusterId, int SecAppId) {
   final String S_ProcName = "deleteSecFormBySecAppIdx";
   if (!schema.isTransactionOpen()) {
     throw CFLib.getDefaultExceptionFactory()
         .newUsageException(getClass(), S_ProcName, "Transaction not open");
   }
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     String sql = "exec sp_delete_secform_by_secappidx ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?";
     if (stmtDeleteBySecAppIdx == null) {
       stmtDeleteBySecAppIdx = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtDeleteBySecAppIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtDeleteBySecAppIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtDeleteBySecAppIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtDeleteBySecAppIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtDeleteBySecAppIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtDeleteBySecAppIdx.setLong(argIdx++, ClusterId);
     stmtDeleteBySecAppIdx.setInt(argIdx++, SecAppId);
     Object stuff = null;
     boolean moreResults = stmtDeleteBySecAppIdx.execute();
     while (stuff == null) {
       try {
         moreResults = stmtDeleteBySecAppIdx.getMoreResults();
       } catch (SQLException e) {
         throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
       }
       if (moreResults) {
         try {
           stuff = stmtDeleteBySecAppIdx.getResultSet();
         } catch (SQLException e) {
         }
       } else if (-1 == stmtDeleteBySecAppIdx.getUpdateCount()) {
         break;
       }
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
  protected CFSecuritySecFormBuff unpackSecFormResultSetToBuff(ResultSet resultSet)
      throws SQLException {
    final String S_ProcName = "unpackSecFormResultSetToBuff";
    int idxcol = 1;
    CFSecuritySecFormBuff buff = schema.getFactorySecForm().newBuff();
    {
      String colString = resultSet.getString(idxcol);
      if (resultSet.wasNull()) {
        buff.setCreatedByUserId(null);
      } else if ((colString == null) || (colString.length() <= 0)) {
        buff.setCreatedByUserId(null);
      } else {
        buff.setCreatedByUserId(UUID.fromString(colString));
      }
      idxcol++;

      colString = resultSet.getString(idxcol);
      if (resultSet.wasNull()) {
        buff.setCreatedAt(null);
      } else if ((colString == null) || (colString.length() <= 0)) {
        buff.setCreatedAt(null);
      } else {
        buff.setCreatedAt(CFFreeSwitchSybaseSchema.convertTimestampString(colString));
      }
      idxcol++;
      colString = resultSet.getString(idxcol);
      if (resultSet.wasNull()) {
        buff.setUpdatedByUserId(null);
      } else if ((colString == null) || (colString.length() <= 0)) {
        buff.setUpdatedByUserId(null);
      } else {
        buff.setUpdatedByUserId(UUID.fromString(colString));
      }
      idxcol++;

      colString = resultSet.getString(idxcol);
      if (resultSet.wasNull()) {
        buff.setUpdatedAt(null);
      } else if ((colString == null) || (colString.length() <= 0)) {
        buff.setUpdatedAt(null);
      } else {
        buff.setUpdatedAt(CFFreeSwitchSybaseSchema.convertTimestampString(colString));
      }
      idxcol++;
    }
    buff.setRequiredClusterId(resultSet.getLong(idxcol));
    idxcol++;
    buff.setRequiredSecFormId(resultSet.getInt(idxcol));
    idxcol++;
    buff.setRequiredSecAppId(resultSet.getInt(idxcol));
    idxcol++;
    buff.setRequiredJEEServletMapName(resultSet.getString(idxcol));
    idxcol++;
    buff.setRequiredRevision(resultSet.getInt(idxcol));
    return (buff);
  }
 public CFSecuritySecFormBuff[] readAllBuff(CFSecurityAuthorization Authorization) {
   final String S_ProcName = "readAllBuff";
   if (!schema.isTransactionOpen()) {
     throw CFLib.getDefaultExceptionFactory()
         .newUsageException(getClass(), S_ProcName, "Transaction not open");
   }
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     String sql = "exec sp_read_secform_all ?, ?, ?, ?, ?";
     if (stmtReadAllBuff == null) {
       stmtReadAllBuff = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtReadAllBuff.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadAllBuff.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtReadAllBuff.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtReadAllBuff.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadAllBuff.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     resultSet = stmtReadAllBuff.executeQuery();
     List<CFSecuritySecFormBuff> buffList = new LinkedList<CFSecuritySecFormBuff>();
     while (resultSet.next()) {
       CFSecuritySecFormBuff buff = unpackSecFormResultSetToBuff(resultSet);
       buffList.add(buff);
     }
     int idx = 0;
     CFSecuritySecFormBuff[] retBuff = new CFSecuritySecFormBuff[buffList.size()];
     Iterator<CFSecuritySecFormBuff> iter = buffList.iterator();
     while (iter.hasNext()) {
       retBuff[idx++] = iter.next();
     }
     return (retBuff);
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
 public CFSecuritySecFormBuff[] readDerivedBySecAppIdx(
     CFSecurityAuthorization Authorization, long ClusterId, int SecAppId) {
   final String S_ProcName = "readDerivedBySecAppIdx";
   if (!schema.isTransactionOpen()) {
     throw CFLib.getDefaultExceptionFactory()
         .newUsageException(getClass(), S_ProcName, "Transaction not open");
   }
   CFSecuritySecFormBuff[] buffList = readBuffBySecAppIdx(Authorization, ClusterId, SecAppId);
   return (buffList);
 }
 public CFSecuritySecFormBuff[] readAllDerived(CFSecurityAuthorization Authorization) {
   final String S_ProcName = "readAllDerived";
   CFSecuritySecFormBuff[] buffArray;
   if (!schema.isTransactionOpen()) {
     throw CFLib.getDefaultExceptionFactory()
         .newUsageException(getClass(), S_ProcName, "Transaction not open");
   }
   buffArray = readAllBuff(Authorization);
   return (buffArray);
 }
 public CFSecuritySecFormBuff readDerivedByIdIdx(
     CFSecurityAuthorization Authorization, long ClusterId, int SecFormId) {
   final String S_ProcName = "CFFreeSwitchSybaseSecFormTable.readDerivedByIdIdx() ";
   CFSecuritySecFormBuff buff;
   if (!schema.isTransactionOpen()) {
     throw CFLib.getDefaultExceptionFactory()
         .newUsageException(getClass(), S_ProcName, "Transaction not open");
   }
   buff = readBuffByIdIdx(Authorization, ClusterId, SecFormId);
   return (buff);
 }
 public CFSecuritySecFormBuff lockDerived(
     CFSecurityAuthorization Authorization, CFSecuritySecFormPKey PKey) {
   final String S_ProcName = "lockDerived";
   if (!schema.isTransactionOpen()) {
     throw CFLib.getDefaultExceptionFactory()
         .newUsageException(getClass(), S_ProcName, "Transaction not open");
   }
   CFSecuritySecFormBuff buff;
   buff = lockBuff(Authorization, PKey);
   return (buff);
 }
 public String getSqlSelectSecFormDistinctClassCode() {
   if (S_sqlSelectSecFormDistinctClassCode == null) {
     S_sqlSelectSecFormDistinctClassCode =
         "SELECT "
             + "DISTINCT sfrm.ClassCode "
             + "FROM "
             + schema.getLowerDbSchemaName()
             + "..SecForm AS sfrm ";
   }
   return (S_sqlSelectSecFormDistinctClassCode);
 }
 public CFSecuritySecFormBuff readBuffByIdIdx(
     CFSecurityAuthorization Authorization, long ClusterId, int SecFormId) {
   final String S_ProcName = "readBuffByIdIdx";
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     String sql = "exec sp_read_secform_by_ididx ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?";
     if (stmtReadBuffByIdIdx == null) {
       stmtReadBuffByIdIdx = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtReadBuffByIdIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByIdIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtReadBuffByIdIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtReadBuffByIdIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByIdIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtReadBuffByIdIdx.setLong(argIdx++, ClusterId);
     stmtReadBuffByIdIdx.setInt(argIdx++, SecFormId);
     resultSet = stmtReadBuffByIdIdx.executeQuery();
     if (resultSet.next()) {
       CFSecuritySecFormBuff buff = unpackSecFormResultSetToBuff(resultSet);
       if (resultSet.next()) {
         resultSet.last();
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(
                 getClass(),
                 S_ProcName,
                 "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
       }
       return (buff);
     } else {
       return (null);
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
 public String getSqlSelectSecFormBuff() {
   if (S_sqlSelectSecFormBuff == null) {
     S_sqlSelectSecFormBuff =
         "SELECT "
             + "sfrm.clusterid, "
             + "sfrm.secformid, "
             + "sfrm.secappid, "
             + "sfrm.jeeservletmapname, "
             + "sfrm.revision "
             + "FROM "
             + schema.getLowerDbSchemaName()
             + "..SecForm AS sfrm ";
   }
   return (S_sqlSelectSecFormBuff);
 }
  public void deleteSecForm(CFSecurityAuthorization Authorization, CFSecuritySecFormBuff Buff) {
    final String S_ProcName = "deleteSecForm";
    try {
      Connection cnx = schema.getCnx();
      long ClusterId = Buff.getRequiredClusterId();
      int SecFormId = Buff.getRequiredSecFormId();

      String sql = "exec sp_delete_secform ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?";
      if (stmtDeleteByPKey == null) {
        stmtDeleteByPKey = cnx.prepareStatement(sql);
      }
      int argIdx = 1;
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
      stmtDeleteByPKey.setString(
          argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
      stmtDeleteByPKey.setString(
          argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
      stmtDeleteByPKey.setLong(argIdx++, ClusterId);
      stmtDeleteByPKey.setInt(argIdx++, SecFormId);
      stmtDeleteByPKey.setInt(argIdx++, Buff.getRequiredRevision());
      ;
      Object stuff = null;
      boolean moreResults = stmtDeleteByPKey.execute();
      while (stuff == null) {
        try {
          moreResults = stmtDeleteByPKey.getMoreResults();
        } catch (SQLException e) {
          throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
        }
        if (moreResults) {
          try {
            stuff = stmtDeleteByPKey.getResultSet();
          } catch (SQLException e) {
          }
        } else if (-1 == stmtDeleteByPKey.getUpdateCount()) {
          break;
        }
      }
    } catch (SQLException e) {
      throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    }
  }
 public void updateSecForm(CFSecurityAuthorization Authorization, CFSecuritySecFormBuff Buff) {
   final String S_ProcName = "updateSecForm";
   ResultSet resultSet = null;
   try {
     long ClusterId = Buff.getRequiredClusterId();
     int SecFormId = Buff.getRequiredSecFormId();
     int SecAppId = Buff.getRequiredSecAppId();
     String JEEServletMapName = Buff.getRequiredJEEServletMapName();
     int Revision = Buff.getRequiredRevision();
     Connection cnx = schema.getCnx();
     String sql =
         "exec sp_update_secform ?, ?, ?, ?, ?, ?"
             + ", "
             + "?"
             + ", "
             + "?"
             + ", "
             + "?"
             + ", "
             + "?"
             + ", "
             + "?";
     if (stmtUpdateByPKey == null) {
       stmtUpdateByPKey = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtUpdateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtUpdateByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtUpdateByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtUpdateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtUpdateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtUpdateByPKey.setString(argIdx++, "SFRM");
     stmtUpdateByPKey.setLong(argIdx++, ClusterId);
     stmtUpdateByPKey.setInt(argIdx++, SecFormId);
     stmtUpdateByPKey.setInt(argIdx++, SecAppId);
     stmtUpdateByPKey.setString(argIdx++, JEEServletMapName);
     stmtUpdateByPKey.setInt(argIdx++, Revision);
     resultSet = stmtUpdateByPKey.executeQuery();
     if (resultSet.next()) {
       CFSecuritySecFormBuff updatedBuff = unpackSecFormResultSetToBuff(resultSet);
       if (resultSet.next()) {
         resultSet.last();
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(
                 getClass(),
                 S_ProcName,
                 "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
       }
       Buff.setRequiredSecAppId(updatedBuff.getRequiredSecAppId());
       Buff.setRequiredJEEServletMapName(updatedBuff.getRequiredJEEServletMapName());
       Buff.setRequiredRevision(updatedBuff.getRequiredRevision());
     } else {
       throw CFLib.getDefaultExceptionFactory()
           .newRuntimeException(
               getClass(),
               S_ProcName,
               "Expected a single-record response, " + resultSet.getRow() + " rows selected");
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }