net.sourceforge.msscodefactory.cffreeswitch.v2_1.CFFswMySql.CFFswMySqlFSSFVMailTable.java Source code

Java tutorial

Introduction

Here is the source code for net.sourceforge.msscodefactory.cffreeswitch.v2_1.CFFswMySql.CFFswMySqlFSSFVMailTable.java

Source

// Description: Java 7 MySQL Jdbc DbIO implementation for FSSFVMail.

/*
 *   CF FreeSwitch Configuration Model
 *
 *   Copyright (c) 2014 Mark Sobkow
 *   
 *   This program is available as free software under the GNU GPL v3, or
 *   under a commercial license from Mark Sobkow.  For commercial licensing
 *   details, please contact msobkow@sasktel.net.
 *   
 *   Under the terms of the GPL:
 *   
 *      This program is free software: you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation, either version 3 of the License, or
 *      (at your option) any later version.
 *     
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *     
 *      You should have received a copy of the GNU General Public License
 *      along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *   
 *      This source code incorporates modified modules originally licensed
 *      under the Apache 2.0 license by MSS Code Factory including CFSecurity
 *      (net-sourceforge-msscodefactory-2.1-cfsecurity.xml),
 *      CFInternet (net-sourceforge-msscodefactory-2.1-cfinternet.xml), and
 *      CFCrm 2.1 (net-sourceforge-msscodefactory-2.1-cfcrm.xml), with all of the
 *      required models being available as part of the MSS Code Factory 2.0
 *      distribution source and install zips.
 *   
 *      You can download installations of MSS Code Factory 2.0 from
 *      http://msscodefactory.sourceforge.net/
 *   
 * ***********************************************************************
 *
 *   Code manufactured by MSS Code Factory
 */

package net.sourceforge.msscodefactory.cffreeswitch.v2_1.CFFswMySql;

import java.math.*;
import java.sql.*;
import java.text.*;
import java.util.*;
import net.sourceforge.msscodefactory.cflib.v2_1.CFLib.*;
import org.apache.commons.codec.binary.Base64;
import net.sourceforge.msscodefactory.cffreeswitch.v2_1.CFFsw.*;

/*
 *   CFFswMySqlFSSFVMailTable MySQL Jdbc DbIO implementation
 *   for FSSFVMail.
 */
public class CFFswMySqlFSSFVMailTable implements ICFFswFSSFVMailTable {
    private CFFswMySqlSchema schema;
    protected PreparedStatement stmtReadBuffByPKey = null;
    protected PreparedStatement stmtLockBuffByPKey = null;
    protected PreparedStatement stmtCreateByPKey = null;
    protected PreparedStatement stmtUpdateByPKey = null;
    protected PreparedStatement stmtDeleteByPKey = null;
    protected PreparedStatement stmtReadAllBuff = null;
    protected PreparedStatement stmtReadBuffByIdIdx = null;
    protected PreparedStatement stmtReadBuffByTenantIdx = null;
    protected PreparedStatement stmtReadBuffBySofiaIdx = null;
    protected PreparedStatement stmtReadBuffByUNameIdx = null;
    protected PreparedStatement stmtDeleteByIdIdx = null;
    protected PreparedStatement stmtDeleteByTenantIdx = null;
    protected PreparedStatement stmtDeleteBySofiaIdx = null;
    protected PreparedStatement stmtDeleteByUNameIdx = null;

    public CFFswMySqlFSSFVMailTable(CFFswMySqlSchema argSchema) {
        schema = argSchema;
    }

    public void createFSSFVMail(CFFswAuthorization Authorization, CFFswFSSFVMailBuff Buff) {
        final String S_ProcName = "createFSSFVMail";
        if (!schema.isTransactionOpen()) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "Transaction not open");
        }
        ResultSet resultSet = null;
        try {
            long TenantId = Buff.getRequiredTenantId();
            long FSSFVMailId = Buff.getRequiredFSSFVMailId();
            long FSSofiaId = Buff.getRequiredFSSofiaId();
            String Name = Buff.getRequiredName();
            String TemplateFile = Buff.getRequiredTemplateFile();
            String NotifyTemplateFile = Buff.getRequiredNotifyTemplateFile();
            String DateFmt = Buff.getRequiredDateFmt();
            String EmailFrom = Buff.getRequiredEmailFrom();
            String FileExtension = Buff.getRequiredFileExtension();
            String TerminatorKey = Buff.getRequiredTerminatorKey();
            short MaxLoginAttempts = Buff.getRequiredMaxLoginAttempts();
            int DigitTimeout = Buff.getRequiredDigitTimeout();
            int MinRecordLen = Buff.getRequiredMinRecordLen();
            int MaxRecordLen = Buff.getRequiredMaxRecordLen();
            short MaxRetries = Buff.getRequiredMaxRetries();
            String ToneSpec = Buff.getRequiredToneSpec();
            String CallbackDialplan = Buff.getRequiredCallbackDialplan();
            String CallbackContext = Buff.getOptionalCallbackContext();
            String PlayNewMessagesKey = Buff.getRequiredPlayNewMessagesKey();
            String PlaySavedMessagesKey = Buff.getRequiredPlaySavedMessagesKey();
            String LoginKeys = Buff.getRequiredLoginKeys();
            String MainMenuKey = Buff.getRequiredMainMenuKey();
            String ConfigMenuKey = Buff.getRequiredConfigMenuKey();
            String RecordGreetingKey = Buff.getRequiredRecordGreetingKey();
            String ChooseGreetingKey = Buff.getRequiredChooseGreetingKey();
            String ChangePassKey = Buff.getRequiredChangePassKey();
            String RecordNameKey = Buff.getRequiredRecordNameKey();
            String RecordFileKey = Buff.getRequiredRecordFileKey();
            String ListenFileKey = Buff.getRequiredListenFileKey();
            String SaveFileKey = Buff.getRequiredSaveFileKey();
            String DeleteFileKey = Buff.getRequiredDeleteFileKey();
            String UndeleteFileKey = Buff.getRequiredUndeleteFileKey();
            String EMailKey = Buff.getRequiredEMailKey();
            String PauseKey = Buff.getRequiredPauseKey();
            String RestartKey = Buff.getRequiredRestartKey();
            String FastForwardKey = Buff.getRequiredFastForwardKey();
            String RewindKey = Buff.getRequiredRewindKey();
            String SkipGreetKey = Buff.getRequiredSkipGreetKey();
            int RecordSilenceThreshold = Buff.getRequiredRecordSilenceThreshold();
            short RecordSilenceHits = Buff.getRequiredRecordSilenceHits();
            String WebTemplateFile = Buff.getRequiredWebTemplateFile();
            int RecordSampleRate = Buff.getRequiredRecordSampleRate();
            String OperatorExtension = Buff.getRequiredOperatorExtension();
            String VMainExtension = Buff.getRequiredVMainExtension();
            String VMailKey = Buff.getRequiredVMailKey();
            boolean AutoPlaybackRecordings = Buff.getRequiredAutoPlaybackRecordings();
            String StorageDir = Buff.getRequiredStorageDir();
            String OdbcDSN = Buff.getOptionalOdbcDSN();
            String RecordComent = Buff.getOptionalRecordComent();
            String RecordTitle = Buff.getOptionalRecordTitle();
            String RecordCopyright = Buff.getOptionalRecordCopyright();
            Connection cnx = schema.getCnx();
            String sql = "call " + schema.getLowerDbSchemaName() + ".sp_create_fssfvm( ?, ?, ?, ?, ?, ?" + ", "
                    + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?"
                    + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?"
                    + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?"
                    + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?"
                    + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?"
                    + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?"
                    + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?"
                    + ", " + "?" + " )";
            if (stmtCreateByPKey == null) {
                stmtCreateByPKey = cnx.prepareStatement(sql);
            }
            int argIdx = 1;
            stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
            stmtCreateByPKey.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecUserId().toString());
            stmtCreateByPKey.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
            stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
            stmtCreateByPKey.setString(argIdx++, "FSVM");
            stmtCreateByPKey.setLong(argIdx++, TenantId);
            stmtCreateByPKey.setLong(argIdx++, FSSFVMailId);
            stmtCreateByPKey.setLong(argIdx++, FSSofiaId);
            stmtCreateByPKey.setString(argIdx++, Name);
            stmtCreateByPKey.setString(argIdx++, TemplateFile);
            stmtCreateByPKey.setString(argIdx++, NotifyTemplateFile);
            stmtCreateByPKey.setString(argIdx++, DateFmt);
            stmtCreateByPKey.setString(argIdx++, EmailFrom);
            stmtCreateByPKey.setString(argIdx++, FileExtension);
            stmtCreateByPKey.setString(argIdx++, TerminatorKey);
            stmtCreateByPKey.setShort(argIdx++, MaxLoginAttempts);
            stmtCreateByPKey.setInt(argIdx++, DigitTimeout);
            stmtCreateByPKey.setInt(argIdx++, MinRecordLen);
            stmtCreateByPKey.setInt(argIdx++, MaxRecordLen);
            stmtCreateByPKey.setShort(argIdx++, MaxRetries);
            stmtCreateByPKey.setString(argIdx++, ToneSpec);
            stmtCreateByPKey.setString(argIdx++, CallbackDialplan);
            if (CallbackContext != null) {
                stmtCreateByPKey.setString(argIdx++, CallbackContext);
            } else {
                stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
            }
            stmtCreateByPKey.setString(argIdx++, PlayNewMessagesKey);
            stmtCreateByPKey.setString(argIdx++, PlaySavedMessagesKey);
            stmtCreateByPKey.setString(argIdx++, LoginKeys);
            stmtCreateByPKey.setString(argIdx++, MainMenuKey);
            stmtCreateByPKey.setString(argIdx++, ConfigMenuKey);
            stmtCreateByPKey.setString(argIdx++, RecordGreetingKey);
            stmtCreateByPKey.setString(argIdx++, ChooseGreetingKey);
            stmtCreateByPKey.setString(argIdx++, ChangePassKey);
            stmtCreateByPKey.setString(argIdx++, RecordNameKey);
            stmtCreateByPKey.setString(argIdx++, RecordFileKey);
            stmtCreateByPKey.setString(argIdx++, ListenFileKey);
            stmtCreateByPKey.setString(argIdx++, SaveFileKey);
            stmtCreateByPKey.setString(argIdx++, DeleteFileKey);
            stmtCreateByPKey.setString(argIdx++, UndeleteFileKey);
            stmtCreateByPKey.setString(argIdx++, EMailKey);
            stmtCreateByPKey.setString(argIdx++, PauseKey);
            stmtCreateByPKey.setString(argIdx++, RestartKey);
            stmtCreateByPKey.setString(argIdx++, FastForwardKey);
            stmtCreateByPKey.setString(argIdx++, RewindKey);
            stmtCreateByPKey.setString(argIdx++, SkipGreetKey);
            stmtCreateByPKey.setInt(argIdx++, RecordSilenceThreshold);
            stmtCreateByPKey.setShort(argIdx++, RecordSilenceHits);
            stmtCreateByPKey.setString(argIdx++, WebTemplateFile);
            stmtCreateByPKey.setInt(argIdx++, RecordSampleRate);
            stmtCreateByPKey.setString(argIdx++, OperatorExtension);
            stmtCreateByPKey.setString(argIdx++, VMainExtension);
            stmtCreateByPKey.setString(argIdx++, VMailKey);
            stmtCreateByPKey.setBoolean(argIdx++, AutoPlaybackRecordings);
            stmtCreateByPKey.setString(argIdx++, StorageDir);
            if (OdbcDSN != null) {
                stmtCreateByPKey.setString(argIdx++, OdbcDSN);
            } else {
                stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
            }
            if (RecordComent != null) {
                stmtCreateByPKey.setString(argIdx++, RecordComent);
            } else {
                stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
            }
            if (RecordTitle != null) {
                stmtCreateByPKey.setString(argIdx++, RecordTitle);
            } else {
                stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
            }
            if (RecordCopyright != null) {
                stmtCreateByPKey.setString(argIdx++, RecordCopyright);
            } else {
                stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
            }
            try {
                resultSet = stmtCreateByPKey.executeQuery();
            } catch (SQLException e) {
                if (e.getErrorCode() != 1329) {
                    throw e;
                }
                resultSet = null;
            }
            if ((resultSet != null) && resultSet.next()) {
                CFFswFSSFVMailBuff createdBuff = unpackFSSFVMailResultSetToBuff(resultSet);
                if ((resultSet != null) && resultSet.next()) {
                    resultSet.last();
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
                }
                Buff.setRequiredTenantId(createdBuff.getRequiredTenantId());
                Buff.setRequiredFSSFVMailId(createdBuff.getRequiredFSSFVMailId());
                Buff.setRequiredFSSofiaId(createdBuff.getRequiredFSSofiaId());
                Buff.setRequiredName(createdBuff.getRequiredName());
                Buff.setRequiredTemplateFile(createdBuff.getRequiredTemplateFile());
                Buff.setRequiredNotifyTemplateFile(createdBuff.getRequiredNotifyTemplateFile());
                Buff.setRequiredDateFmt(createdBuff.getRequiredDateFmt());
                Buff.setRequiredEmailFrom(createdBuff.getRequiredEmailFrom());
                Buff.setRequiredFileExtension(createdBuff.getRequiredFileExtension());
                Buff.setRequiredTerminatorKey(createdBuff.getRequiredTerminatorKey());
                Buff.setRequiredMaxLoginAttempts(createdBuff.getRequiredMaxLoginAttempts());
                Buff.setRequiredDigitTimeout(createdBuff.getRequiredDigitTimeout());
                Buff.setRequiredMinRecordLen(createdBuff.getRequiredMinRecordLen());
                Buff.setRequiredMaxRecordLen(createdBuff.getRequiredMaxRecordLen());
                Buff.setRequiredMaxRetries(createdBuff.getRequiredMaxRetries());
                Buff.setRequiredToneSpec(createdBuff.getRequiredToneSpec());
                Buff.setRequiredCallbackDialplan(createdBuff.getRequiredCallbackDialplan());
                Buff.setOptionalCallbackContext(createdBuff.getOptionalCallbackContext());
                Buff.setRequiredPlayNewMessagesKey(createdBuff.getRequiredPlayNewMessagesKey());
                Buff.setRequiredPlaySavedMessagesKey(createdBuff.getRequiredPlaySavedMessagesKey());
                Buff.setRequiredLoginKeys(createdBuff.getRequiredLoginKeys());
                Buff.setRequiredMainMenuKey(createdBuff.getRequiredMainMenuKey());
                Buff.setRequiredConfigMenuKey(createdBuff.getRequiredConfigMenuKey());
                Buff.setRequiredRecordGreetingKey(createdBuff.getRequiredRecordGreetingKey());
                Buff.setRequiredChooseGreetingKey(createdBuff.getRequiredChooseGreetingKey());
                Buff.setRequiredChangePassKey(createdBuff.getRequiredChangePassKey());
                Buff.setRequiredRecordNameKey(createdBuff.getRequiredRecordNameKey());
                Buff.setRequiredRecordFileKey(createdBuff.getRequiredRecordFileKey());
                Buff.setRequiredListenFileKey(createdBuff.getRequiredListenFileKey());
                Buff.setRequiredSaveFileKey(createdBuff.getRequiredSaveFileKey());
                Buff.setRequiredDeleteFileKey(createdBuff.getRequiredDeleteFileKey());
                Buff.setRequiredUndeleteFileKey(createdBuff.getRequiredUndeleteFileKey());
                Buff.setRequiredEMailKey(createdBuff.getRequiredEMailKey());
                Buff.setRequiredPauseKey(createdBuff.getRequiredPauseKey());
                Buff.setRequiredRestartKey(createdBuff.getRequiredRestartKey());
                Buff.setRequiredFastForwardKey(createdBuff.getRequiredFastForwardKey());
                Buff.setRequiredRewindKey(createdBuff.getRequiredRewindKey());
                Buff.setRequiredSkipGreetKey(createdBuff.getRequiredSkipGreetKey());
                Buff.setRequiredRecordSilenceThreshold(createdBuff.getRequiredRecordSilenceThreshold());
                Buff.setRequiredRecordSilenceHits(createdBuff.getRequiredRecordSilenceHits());
                Buff.setRequiredWebTemplateFile(createdBuff.getRequiredWebTemplateFile());
                Buff.setRequiredRecordSampleRate(createdBuff.getRequiredRecordSampleRate());
                Buff.setRequiredOperatorExtension(createdBuff.getRequiredOperatorExtension());
                Buff.setRequiredVMainExtension(createdBuff.getRequiredVMainExtension());
                Buff.setRequiredVMailKey(createdBuff.getRequiredVMailKey());
                Buff.setRequiredAutoPlaybackRecordings(createdBuff.getRequiredAutoPlaybackRecordings());
                Buff.setRequiredStorageDir(createdBuff.getRequiredStorageDir());
                Buff.setOptionalOdbcDSN(createdBuff.getOptionalOdbcDSN());
                Buff.setOptionalRecordComent(createdBuff.getOptionalRecordComent());
                Buff.setOptionalRecordTitle(createdBuff.getOptionalRecordTitle());
                Buff.setOptionalRecordCopyright(createdBuff.getOptionalRecordCopyright());
                Buff.setRequiredRevision(createdBuff.getRequiredRevision());
                Buff.setCreatedByUserId(createdBuff.getCreatedByUserId());
                Buff.setCreatedAt(createdBuff.getCreatedAt());
                Buff.setUpdatedByUserId(createdBuff.getUpdatedByUserId());
                Buff.setUpdatedAt(createdBuff.getUpdatedAt());
            } 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;
            }
        }
    }

    protected static String S_sqlSelectFSSFVMailDistinctClassCode = null;

    public String getSqlSelectFSSFVMailDistinctClassCode() {
        if (S_sqlSelectFSSFVMailDistinctClassCode == null) {
            S_sqlSelectFSSFVMailDistinctClassCode = "SELECT " + "DISTINCT fsvm.ClassCode " + "FROM "
                    + schema.getLowerDbSchemaName() + ".FSSFVM AS fsvm ";
        }
        return (S_sqlSelectFSSFVMailDistinctClassCode);
    }

    protected static String S_sqlSelectFSSFVMailBuff = null;

    public String getSqlSelectFSSFVMailBuff() {
        if (S_sqlSelectFSSFVMailBuff == null) {
            S_sqlSelectFSSFVMailBuff = "SELECT " + "fsvm.TenantId, " + "fsvm.FSSFVMailId, " + "fsvm.FSSofiaId, "
                    + "fsvm.Name, " + "fsvm.TemplateFile, " + "fsvm.NotifyTemplateFile, " + "fsvm.DateFmt, "
                    + "fsvm.EmailFrom, " + "fsvm.FileExtension, " + "fsvm.TerminatorKey, "
                    + "fsvm.MaxLoginAttempts, " + "fsvm.DigitTimeout, " + "fsvm.MinRecordLen, "
                    + "fsvm.MaxRecordLen, " + "fsvm.MaxRetries, " + "fsvm.ToneSpec, " + "fsvm.CallbackDialplan, "
                    + "fsvm.CallbackContext, " + "fsvm.PlayNewMessagesKey, " + "fsvm.PlaySavedMessagesKey, "
                    + "fsvm.LoginKeys, " + "fsvm.MainMenuKey, " + "fsvm.ConfigMenuKey, "
                    + "fsvm.RecordGreetingKey, " + "fsvm.ChooseGreetingKey, " + "fsvm.ChangePassKey, "
                    + "fsvm.RecordNameKey, " + "fsvm.RecordFileKey, " + "fsvm.ListenFileKey, "
                    + "fsvm.SaveFileKey, " + "fsvm.DeleteFileKey, " + "fsvm.UndeleteFileKey, " + "fsvm.EMailKey, "
                    + "fsvm.PauseKey, " + "fsvm.RestartKey, " + "fsvm.FastForwardKey, " + "fsvm.RewindKey, "
                    + "fsvm.SkipGreetKey, " + "fsvm.RecordSilenceThreshold, " + "fsvm.RecordSilenceHits, "
                    + "fsvm.WebTemplateFile, " + "fsvm.RecordSampleRate, " + "fsvm.OperatorExtension, "
                    + "fsvm.VMainExtension, " + "fsvm.VMailKey, " + "fsvm.AutoPlaybackRecordings, "
                    + "fsvm.StorageDir, " + "fsvm.OdbcDSN, " + "fsvm.RecordComent, " + "fsvm.RecordTitle, "
                    + "fsvm.RecordCopyright, " + "fsvm.Revision " + "FROM " + schema.getLowerDbSchemaName()
                    + ".FSSFVM AS fsvm ";
        }
        return (S_sqlSelectFSSFVMailBuff);
    }

    protected CFFswFSSFVMailBuff unpackFSSFVMailResultSetToBuff(ResultSet resultSet) throws SQLException {
        final String S_ProcName = "unpackFSSFVMailResultSetToBuff";
        int idxcol = 1;
        CFFswFSSFVMailBuff buff = schema.getFactoryFSSFVMail().newBuff();
        {
            String colString = resultSet.getString(idxcol);
            if (resultSet.wasNull()) {
                buff.setCreatedAt(null);
            } else if ((colString == null) || (colString.length() <= 0)) {
                buff.setCreatedAt(null);
            } else {
                buff.setCreatedAt(CFFswMySqlSchema.convertTimestampString(colString));
            }
        }
        idxcol++;
        {
            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++;
        {
            String colString = resultSet.getString(idxcol);
            if (resultSet.wasNull()) {
                buff.setUpdatedAt(null);
            } else if ((colString == null) || (colString.length() <= 0)) {
                buff.setUpdatedAt(null);
            } else {
                buff.setUpdatedAt(CFFswMySqlSchema.convertTimestampString(colString));
            }
        }
        idxcol++;
        {
            String 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++;
        buff.setRequiredTenantId(resultSet.getLong(idxcol));
        idxcol++;
        buff.setRequiredFSSFVMailId(resultSet.getLong(idxcol));
        idxcol++;
        buff.setRequiredFSSofiaId(resultSet.getLong(idxcol));
        idxcol++;
        buff.setRequiredName(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredTemplateFile(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredNotifyTemplateFile(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredDateFmt(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredEmailFrom(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredFileExtension(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredTerminatorKey(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredMaxLoginAttempts(resultSet.getShort(idxcol));
        idxcol++;
        buff.setRequiredDigitTimeout(resultSet.getInt(idxcol));
        idxcol++;
        buff.setRequiredMinRecordLen(resultSet.getInt(idxcol));
        idxcol++;
        buff.setRequiredMaxRecordLen(resultSet.getInt(idxcol));
        idxcol++;
        buff.setRequiredMaxRetries(resultSet.getShort(idxcol));
        idxcol++;
        buff.setRequiredToneSpec(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredCallbackDialplan(resultSet.getString(idxcol));
        idxcol++;
        {
            String colVal = resultSet.getString(idxcol);
            if (resultSet.wasNull()) {
                buff.setOptionalCallbackContext(null);
            } else {
                buff.setOptionalCallbackContext(colVal);
            }
        }
        idxcol++;
        buff.setRequiredPlayNewMessagesKey(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredPlaySavedMessagesKey(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredLoginKeys(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredMainMenuKey(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredConfigMenuKey(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredRecordGreetingKey(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredChooseGreetingKey(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredChangePassKey(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredRecordNameKey(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredRecordFileKey(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredListenFileKey(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredSaveFileKey(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredDeleteFileKey(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredUndeleteFileKey(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredEMailKey(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredPauseKey(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredRestartKey(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredFastForwardKey(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredRewindKey(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredSkipGreetKey(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredRecordSilenceThreshold(resultSet.getInt(idxcol));
        idxcol++;
        buff.setRequiredRecordSilenceHits(resultSet.getShort(idxcol));
        idxcol++;
        buff.setRequiredWebTemplateFile(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredRecordSampleRate(resultSet.getInt(idxcol));
        idxcol++;
        buff.setRequiredOperatorExtension(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredVMainExtension(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredVMailKey(resultSet.getString(idxcol));
        idxcol++;
        buff.setRequiredAutoPlaybackRecordings(resultSet.getBoolean(idxcol));
        idxcol++;
        buff.setRequiredStorageDir(resultSet.getString(idxcol));
        idxcol++;
        {
            String colVal = resultSet.getString(idxcol);
            if (resultSet.wasNull()) {
                buff.setOptionalOdbcDSN(null);
            } else {
                buff.setOptionalOdbcDSN(colVal);
            }
        }
        idxcol++;
        {
            String colVal = resultSet.getString(idxcol);
            if (resultSet.wasNull()) {
                buff.setOptionalRecordComent(null);
            } else {
                buff.setOptionalRecordComent(colVal);
            }
        }
        idxcol++;
        {
            String colVal = resultSet.getString(idxcol);
            if (resultSet.wasNull()) {
                buff.setOptionalRecordTitle(null);
            } else {
                buff.setOptionalRecordTitle(colVal);
            }
        }
        idxcol++;
        {
            String colVal = resultSet.getString(idxcol);
            if (resultSet.wasNull()) {
                buff.setOptionalRecordCopyright(null);
            } else {
                buff.setOptionalRecordCopyright(colVal);
            }
        }
        idxcol++;

        buff.setRequiredRevision(resultSet.getInt(idxcol));
        return (buff);
    }

    public CFFswFSSFVMailBuff readDerived(CFFswAuthorization Authorization, CFFswFSSFVMailPKey PKey) {
        final String S_ProcName = "readDerived";
        if (!schema.isTransactionOpen()) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "Transaction not open");
        }
        CFFswFSSFVMailBuff buff;
        buff = readBuff(Authorization, PKey);
        return (buff);
    }

    public CFFswFSSFVMailBuff lockDerived(CFFswAuthorization Authorization, CFFswFSSFVMailPKey PKey) {
        final String S_ProcName = "lockDerived";
        if (!schema.isTransactionOpen()) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "Transaction not open");
        }
        CFFswFSSFVMailBuff buff;
        buff = lockBuff(Authorization, PKey);
        return (buff);
    }

    public CFFswFSSFVMailBuff[] readAllDerived(CFFswAuthorization Authorization) {
        final String S_ProcName = "readAllDerived";
        CFFswFSSFVMailBuff[] buffArray;
        if (!schema.isTransactionOpen()) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "Transaction not open");
        }
        buffArray = readAllBuff(Authorization);
        return (buffArray);
    }

    public CFFswFSSFVMailBuff readDerivedByIdIdx(CFFswAuthorization Authorization, long TenantId,
            long FSSFVMailId) {
        final String S_ProcName = "CFFswMySqlFSSFVMailTable.readDerivedByIdIdx() ";
        CFFswFSSFVMailBuff buff;
        if (!schema.isTransactionOpen()) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "Transaction not open");
        }
        buff = readBuffByIdIdx(Authorization, TenantId, FSSFVMailId);
        return (buff);
    }

    public CFFswFSSFVMailBuff[] readDerivedByTenantIdx(CFFswAuthorization Authorization, long TenantId) {
        final String S_ProcName = "readDerivedByTenantIdx";
        if (!schema.isTransactionOpen()) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "Transaction not open");
        }
        CFFswFSSFVMailBuff[] buffList = readBuffByTenantIdx(Authorization, TenantId);
        return (buffList);

    }

    public CFFswFSSFVMailBuff[] readDerivedBySofiaIdx(CFFswAuthorization Authorization, long TenantId,
            long FSSofiaId) {
        final String S_ProcName = "readDerivedBySofiaIdx";
        if (!schema.isTransactionOpen()) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "Transaction not open");
        }
        CFFswFSSFVMailBuff[] buffList = readBuffBySofiaIdx(Authorization, TenantId, FSSofiaId);
        return (buffList);

    }

    public CFFswFSSFVMailBuff[] readDerivedByUNameIdx(CFFswAuthorization Authorization, long TenantId,
            long FSSofiaId, String Name) {
        final String S_ProcName = "readDerivedByUNameIdx";
        if (!schema.isTransactionOpen()) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "Transaction not open");
        }
        CFFswFSSFVMailBuff[] buffList = readBuffByUNameIdx(Authorization, TenantId, FSSofiaId, Name);
        return (buffList);

    }

    public CFFswFSSFVMailBuff readBuff(CFFswAuthorization Authorization, CFFswFSSFVMailPKey PKey) {
        final String S_ProcName = "readBuff";
        if (!schema.isTransactionOpen()) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "Transaction not open");
        }
        ResultSet resultSet = null;
        try {
            Connection cnx = schema.getCnx();
            long TenantId = PKey.getRequiredTenantId();
            long FSSFVMailId = PKey.getRequiredFSSFVMailId();
            String sql = "call " + schema.getLowerDbSchemaName() + ".sp_read_fssfvm( ?, ?, ?, ?, ?" + ", " + "?"
                    + ", " + "?" + " )";
            if (stmtReadBuffByPKey == null) {
                stmtReadBuffByPKey = cnx.prepareStatement(sql);
            }
            int argIdx = 1;
            stmtReadBuffByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtReadBuffByPKey.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecUserId().toString());
            stmtReadBuffByPKey.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
            stmtReadBuffByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtReadBuffByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
            stmtReadBuffByPKey.setLong(argIdx++, TenantId);
            stmtReadBuffByPKey.setLong(argIdx++, FSSFVMailId);
            try {
                resultSet = stmtReadBuffByPKey.executeQuery();
            } catch (SQLException e) {
                if (e.getErrorCode() != 1329) {
                    throw e;
                }
                resultSet = null;
            }
            if ((resultSet != null) && resultSet.next()) {
                CFFswFSSFVMailBuff buff = unpackFSSFVMailResultSetToBuff(resultSet);
                if ((resultSet != null) && 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 CFFswFSSFVMailBuff lockBuff(CFFswAuthorization Authorization, CFFswFSSFVMailPKey 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 TenantId = PKey.getRequiredTenantId();
            long FSSFVMailId = PKey.getRequiredFSSFVMailId();
            String sql = "call " + schema.getLowerDbSchemaName() + ".sp_lock_fssfvm( ?, ?, ?, ?, ?" + ", " + "?"
                    + ", " + "?" + " )";
            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++, TenantId);
            stmtLockBuffByPKey.setLong(argIdx++, FSSFVMailId);
            try {
                resultSet = stmtLockBuffByPKey.executeQuery();
            } catch (SQLException e) {
                if (e.getErrorCode() != 1329) {
                    throw e;
                }
                resultSet = null;
            }
            if ((resultSet != null) && resultSet.next()) {
                CFFswFSSFVMailBuff buff = unpackFSSFVMailResultSetToBuff(resultSet);
                if ((resultSet != null) && 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 CFFswFSSFVMailBuff[] readAllBuff(CFFswAuthorization 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 = "call " + schema.getLowerDbSchemaName() + ".sp_read_fssfvm_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());
            try {
                resultSet = stmtReadAllBuff.executeQuery();
            } catch (SQLException e) {
                if (e.getErrorCode() != 1329) {
                    throw e;
                }
                resultSet = null;
            }
            List<CFFswFSSFVMailBuff> buffList = new LinkedList<CFFswFSSFVMailBuff>();
            while ((resultSet != null) && resultSet.next()) {
                CFFswFSSFVMailBuff buff = unpackFSSFVMailResultSetToBuff(resultSet);
                buffList.add(buff);
            }
            int idx = 0;
            CFFswFSSFVMailBuff[] retBuff = new CFFswFSSFVMailBuff[buffList.size()];
            Iterator<CFFswFSSFVMailBuff> 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 CFFswFSSFVMailBuff readBuffByIdIdx(CFFswAuthorization Authorization, long TenantId, long FSSFVMailId) {
        final String S_ProcName = "readBuffByIdIdx";
        ResultSet resultSet = null;
        try {
            Connection cnx = schema.getCnx();
            String sql = "call " + schema.getLowerDbSchemaName() + ".sp_read_fssfvm_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++, TenantId);
            stmtReadBuffByIdIdx.setLong(argIdx++, FSSFVMailId);
            try {
                resultSet = stmtReadBuffByIdIdx.executeQuery();
            } catch (SQLException e) {
                if (e.getErrorCode() != 1329) {
                    throw e;
                }
                resultSet = null;
            }
            if ((resultSet != null) && resultSet.next()) {
                CFFswFSSFVMailBuff buff = unpackFSSFVMailResultSetToBuff(resultSet);
                if ((resultSet != null) && 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 CFFswFSSFVMailBuff[] readBuffByTenantIdx(CFFswAuthorization Authorization, long TenantId) {
        final String S_ProcName = "readBuffByTenantIdx";
        ResultSet resultSet = null;
        try {
            Connection cnx = schema.getCnx();
            String sql = "call " + schema.getLowerDbSchemaName() + ".sp_read_fssfvm_by_tenantidx( ?, ?, ?, ?, ?"
                    + ", " + "?" + " )";
            if (stmtReadBuffByTenantIdx == null) {
                stmtReadBuffByTenantIdx = cnx.prepareStatement(sql);
            }
            int argIdx = 1;
            stmtReadBuffByTenantIdx.setLong(argIdx++,
                    (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtReadBuffByTenantIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecUserId().toString());
            stmtReadBuffByTenantIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
            stmtReadBuffByTenantIdx.setLong(argIdx++,
                    (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtReadBuffByTenantIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
            stmtReadBuffByTenantIdx.setLong(argIdx++, TenantId);
            try {
                resultSet = stmtReadBuffByTenantIdx.executeQuery();
            } catch (SQLException e) {
                if (e.getErrorCode() != 1329) {
                    throw e;
                }
                resultSet = null;
            }
            List<CFFswFSSFVMailBuff> buffList = new LinkedList<CFFswFSSFVMailBuff>();
            while ((resultSet != null) && resultSet.next()) {
                CFFswFSSFVMailBuff buff = unpackFSSFVMailResultSetToBuff(resultSet);
                buffList.add(buff);
            }
            int idx = 0;
            CFFswFSSFVMailBuff[] retBuff = new CFFswFSSFVMailBuff[buffList.size()];
            Iterator<CFFswFSSFVMailBuff> 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 CFFswFSSFVMailBuff[] readBuffBySofiaIdx(CFFswAuthorization Authorization, long TenantId,
            long FSSofiaId) {
        final String S_ProcName = "readBuffBySofiaIdx";
        ResultSet resultSet = null;
        try {
            Connection cnx = schema.getCnx();
            String sql = "call " + schema.getLowerDbSchemaName() + ".sp_read_fssfvm_by_sofiaidx( ?, ?, ?, ?, ?"
                    + ", " + "?" + ", " + "?" + " )";
            if (stmtReadBuffBySofiaIdx == null) {
                stmtReadBuffBySofiaIdx = cnx.prepareStatement(sql);
            }
            int argIdx = 1;
            stmtReadBuffBySofiaIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtReadBuffBySofiaIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecUserId().toString());
            stmtReadBuffBySofiaIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
            stmtReadBuffBySofiaIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtReadBuffBySofiaIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
            stmtReadBuffBySofiaIdx.setLong(argIdx++, TenantId);
            stmtReadBuffBySofiaIdx.setLong(argIdx++, FSSofiaId);
            try {
                resultSet = stmtReadBuffBySofiaIdx.executeQuery();
            } catch (SQLException e) {
                if (e.getErrorCode() != 1329) {
                    throw e;
                }
                resultSet = null;
            }
            List<CFFswFSSFVMailBuff> buffList = new LinkedList<CFFswFSSFVMailBuff>();
            while ((resultSet != null) && resultSet.next()) {
                CFFswFSSFVMailBuff buff = unpackFSSFVMailResultSetToBuff(resultSet);
                buffList.add(buff);
            }
            int idx = 0;
            CFFswFSSFVMailBuff[] retBuff = new CFFswFSSFVMailBuff[buffList.size()];
            Iterator<CFFswFSSFVMailBuff> 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 CFFswFSSFVMailBuff[] readBuffByUNameIdx(CFFswAuthorization Authorization, long TenantId, long FSSofiaId,
            String Name) {
        final String S_ProcName = "readBuffByUNameIdx";
        ResultSet resultSet = null;
        try {
            Connection cnx = schema.getCnx();
            String sql = "call " + schema.getLowerDbSchemaName() + ".sp_read_fssfvm_by_unameidx( ?, ?, ?, ?, ?"
                    + ", " + "?" + ", " + "?" + ", " + "?" + " )";
            if (stmtReadBuffByUNameIdx == null) {
                stmtReadBuffByUNameIdx = cnx.prepareStatement(sql);
            }
            int argIdx = 1;
            stmtReadBuffByUNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtReadBuffByUNameIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecUserId().toString());
            stmtReadBuffByUNameIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
            stmtReadBuffByUNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtReadBuffByUNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
            stmtReadBuffByUNameIdx.setLong(argIdx++, TenantId);
            stmtReadBuffByUNameIdx.setLong(argIdx++, FSSofiaId);
            stmtReadBuffByUNameIdx.setString(argIdx++, Name);
            try {
                resultSet = stmtReadBuffByUNameIdx.executeQuery();
            } catch (SQLException e) {
                if (e.getErrorCode() != 1329) {
                    throw e;
                }
                resultSet = null;
            }
            List<CFFswFSSFVMailBuff> buffList = new LinkedList<CFFswFSSFVMailBuff>();
            while ((resultSet != null) && resultSet.next()) {
                CFFswFSSFVMailBuff buff = unpackFSSFVMailResultSetToBuff(resultSet);
                buffList.add(buff);
            }
            int idx = 0;
            CFFswFSSFVMailBuff[] retBuff = new CFFswFSSFVMailBuff[buffList.size()];
            Iterator<CFFswFSSFVMailBuff> 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 void updateFSSFVMail(CFFswAuthorization Authorization, CFFswFSSFVMailBuff Buff) {
        final String S_ProcName = "updateFSSFVMail";
        ResultSet resultSet = null;
        try {
            long TenantId = Buff.getRequiredTenantId();
            long FSSFVMailId = Buff.getRequiredFSSFVMailId();
            long FSSofiaId = Buff.getRequiredFSSofiaId();
            String Name = Buff.getRequiredName();
            String TemplateFile = Buff.getRequiredTemplateFile();
            String NotifyTemplateFile = Buff.getRequiredNotifyTemplateFile();
            String DateFmt = Buff.getRequiredDateFmt();
            String EmailFrom = Buff.getRequiredEmailFrom();
            String FileExtension = Buff.getRequiredFileExtension();
            String TerminatorKey = Buff.getRequiredTerminatorKey();
            short MaxLoginAttempts = Buff.getRequiredMaxLoginAttempts();
            int DigitTimeout = Buff.getRequiredDigitTimeout();
            int MinRecordLen = Buff.getRequiredMinRecordLen();
            int MaxRecordLen = Buff.getRequiredMaxRecordLen();
            short MaxRetries = Buff.getRequiredMaxRetries();
            String ToneSpec = Buff.getRequiredToneSpec();
            String CallbackDialplan = Buff.getRequiredCallbackDialplan();
            String CallbackContext = Buff.getOptionalCallbackContext();
            String PlayNewMessagesKey = Buff.getRequiredPlayNewMessagesKey();
            String PlaySavedMessagesKey = Buff.getRequiredPlaySavedMessagesKey();
            String LoginKeys = Buff.getRequiredLoginKeys();
            String MainMenuKey = Buff.getRequiredMainMenuKey();
            String ConfigMenuKey = Buff.getRequiredConfigMenuKey();
            String RecordGreetingKey = Buff.getRequiredRecordGreetingKey();
            String ChooseGreetingKey = Buff.getRequiredChooseGreetingKey();
            String ChangePassKey = Buff.getRequiredChangePassKey();
            String RecordNameKey = Buff.getRequiredRecordNameKey();
            String RecordFileKey = Buff.getRequiredRecordFileKey();
            String ListenFileKey = Buff.getRequiredListenFileKey();
            String SaveFileKey = Buff.getRequiredSaveFileKey();
            String DeleteFileKey = Buff.getRequiredDeleteFileKey();
            String UndeleteFileKey = Buff.getRequiredUndeleteFileKey();
            String EMailKey = Buff.getRequiredEMailKey();
            String PauseKey = Buff.getRequiredPauseKey();
            String RestartKey = Buff.getRequiredRestartKey();
            String FastForwardKey = Buff.getRequiredFastForwardKey();
            String RewindKey = Buff.getRequiredRewindKey();
            String SkipGreetKey = Buff.getRequiredSkipGreetKey();
            int RecordSilenceThreshold = Buff.getRequiredRecordSilenceThreshold();
            short RecordSilenceHits = Buff.getRequiredRecordSilenceHits();
            String WebTemplateFile = Buff.getRequiredWebTemplateFile();
            int RecordSampleRate = Buff.getRequiredRecordSampleRate();
            String OperatorExtension = Buff.getRequiredOperatorExtension();
            String VMainExtension = Buff.getRequiredVMainExtension();
            String VMailKey = Buff.getRequiredVMailKey();
            boolean AutoPlaybackRecordings = Buff.getRequiredAutoPlaybackRecordings();
            String StorageDir = Buff.getRequiredStorageDir();
            String OdbcDSN = Buff.getOptionalOdbcDSN();
            String RecordComent = Buff.getOptionalRecordComent();
            String RecordTitle = Buff.getOptionalRecordTitle();
            String RecordCopyright = Buff.getOptionalRecordCopyright();
            int Revision = Buff.getRequiredRevision();
            Connection cnx = schema.getCnx();
            String sql = "call " + schema.getLowerDbSchemaName() + ".sp_update_fssfvm( ?, ?, ?, ?, ?, ?" + ", "
                    + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?"
                    + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?"
                    + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?"
                    + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?"
                    + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?"
                    + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?"
                    + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?"
                    + ", " + "?" + ", " + "?" + " )";
            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++, "FSVM");
            stmtUpdateByPKey.setLong(argIdx++, TenantId);
            stmtUpdateByPKey.setLong(argIdx++, FSSFVMailId);
            stmtUpdateByPKey.setLong(argIdx++, FSSofiaId);
            stmtUpdateByPKey.setString(argIdx++, Name);
            stmtUpdateByPKey.setString(argIdx++, TemplateFile);
            stmtUpdateByPKey.setString(argIdx++, NotifyTemplateFile);
            stmtUpdateByPKey.setString(argIdx++, DateFmt);
            stmtUpdateByPKey.setString(argIdx++, EmailFrom);
            stmtUpdateByPKey.setString(argIdx++, FileExtension);
            stmtUpdateByPKey.setString(argIdx++, TerminatorKey);
            stmtUpdateByPKey.setShort(argIdx++, MaxLoginAttempts);
            stmtUpdateByPKey.setInt(argIdx++, DigitTimeout);
            stmtUpdateByPKey.setInt(argIdx++, MinRecordLen);
            stmtUpdateByPKey.setInt(argIdx++, MaxRecordLen);
            stmtUpdateByPKey.setShort(argIdx++, MaxRetries);
            stmtUpdateByPKey.setString(argIdx++, ToneSpec);
            stmtUpdateByPKey.setString(argIdx++, CallbackDialplan);
            if (CallbackContext != null) {
                stmtUpdateByPKey.setString(argIdx++, CallbackContext);
            } else {
                stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
            }
            stmtUpdateByPKey.setString(argIdx++, PlayNewMessagesKey);
            stmtUpdateByPKey.setString(argIdx++, PlaySavedMessagesKey);
            stmtUpdateByPKey.setString(argIdx++, LoginKeys);
            stmtUpdateByPKey.setString(argIdx++, MainMenuKey);
            stmtUpdateByPKey.setString(argIdx++, ConfigMenuKey);
            stmtUpdateByPKey.setString(argIdx++, RecordGreetingKey);
            stmtUpdateByPKey.setString(argIdx++, ChooseGreetingKey);
            stmtUpdateByPKey.setString(argIdx++, ChangePassKey);
            stmtUpdateByPKey.setString(argIdx++, RecordNameKey);
            stmtUpdateByPKey.setString(argIdx++, RecordFileKey);
            stmtUpdateByPKey.setString(argIdx++, ListenFileKey);
            stmtUpdateByPKey.setString(argIdx++, SaveFileKey);
            stmtUpdateByPKey.setString(argIdx++, DeleteFileKey);
            stmtUpdateByPKey.setString(argIdx++, UndeleteFileKey);
            stmtUpdateByPKey.setString(argIdx++, EMailKey);
            stmtUpdateByPKey.setString(argIdx++, PauseKey);
            stmtUpdateByPKey.setString(argIdx++, RestartKey);
            stmtUpdateByPKey.setString(argIdx++, FastForwardKey);
            stmtUpdateByPKey.setString(argIdx++, RewindKey);
            stmtUpdateByPKey.setString(argIdx++, SkipGreetKey);
            stmtUpdateByPKey.setInt(argIdx++, RecordSilenceThreshold);
            stmtUpdateByPKey.setShort(argIdx++, RecordSilenceHits);
            stmtUpdateByPKey.setString(argIdx++, WebTemplateFile);
            stmtUpdateByPKey.setInt(argIdx++, RecordSampleRate);
            stmtUpdateByPKey.setString(argIdx++, OperatorExtension);
            stmtUpdateByPKey.setString(argIdx++, VMainExtension);
            stmtUpdateByPKey.setString(argIdx++, VMailKey);
            stmtUpdateByPKey.setBoolean(argIdx++, AutoPlaybackRecordings);
            stmtUpdateByPKey.setString(argIdx++, StorageDir);
            if (OdbcDSN != null) {
                stmtUpdateByPKey.setString(argIdx++, OdbcDSN);
            } else {
                stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
            }
            if (RecordComent != null) {
                stmtUpdateByPKey.setString(argIdx++, RecordComent);
            } else {
                stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
            }
            if (RecordTitle != null) {
                stmtUpdateByPKey.setString(argIdx++, RecordTitle);
            } else {
                stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
            }
            if (RecordCopyright != null) {
                stmtUpdateByPKey.setString(argIdx++, RecordCopyright);
            } else {
                stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
            }
            stmtUpdateByPKey.setInt(argIdx++, Revision);
            try {
                resultSet = stmtUpdateByPKey.executeQuery();
            } catch (SQLException e) {
                if (e.getErrorCode() != 1329) {
                    throw e;
                }
                resultSet = null;
            }
            if ((resultSet != null) && resultSet.next()) {
                CFFswFSSFVMailBuff updatedBuff = unpackFSSFVMailResultSetToBuff(resultSet);
                if ((resultSet != null) && resultSet.next()) {
                    resultSet.last();
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
                }
                Buff.setRequiredFSSofiaId(updatedBuff.getRequiredFSSofiaId());
                Buff.setRequiredName(updatedBuff.getRequiredName());
                Buff.setRequiredTemplateFile(updatedBuff.getRequiredTemplateFile());
                Buff.setRequiredNotifyTemplateFile(updatedBuff.getRequiredNotifyTemplateFile());
                Buff.setRequiredDateFmt(updatedBuff.getRequiredDateFmt());
                Buff.setRequiredEmailFrom(updatedBuff.getRequiredEmailFrom());
                Buff.setRequiredFileExtension(updatedBuff.getRequiredFileExtension());
                Buff.setRequiredTerminatorKey(updatedBuff.getRequiredTerminatorKey());
                Buff.setRequiredMaxLoginAttempts(updatedBuff.getRequiredMaxLoginAttempts());
                Buff.setRequiredDigitTimeout(updatedBuff.getRequiredDigitTimeout());
                Buff.setRequiredMinRecordLen(updatedBuff.getRequiredMinRecordLen());
                Buff.setRequiredMaxRecordLen(updatedBuff.getRequiredMaxRecordLen());
                Buff.setRequiredMaxRetries(updatedBuff.getRequiredMaxRetries());
                Buff.setRequiredToneSpec(updatedBuff.getRequiredToneSpec());
                Buff.setRequiredCallbackDialplan(updatedBuff.getRequiredCallbackDialplan());
                Buff.setOptionalCallbackContext(updatedBuff.getOptionalCallbackContext());
                Buff.setRequiredPlayNewMessagesKey(updatedBuff.getRequiredPlayNewMessagesKey());
                Buff.setRequiredPlaySavedMessagesKey(updatedBuff.getRequiredPlaySavedMessagesKey());
                Buff.setRequiredLoginKeys(updatedBuff.getRequiredLoginKeys());
                Buff.setRequiredMainMenuKey(updatedBuff.getRequiredMainMenuKey());
                Buff.setRequiredConfigMenuKey(updatedBuff.getRequiredConfigMenuKey());
                Buff.setRequiredRecordGreetingKey(updatedBuff.getRequiredRecordGreetingKey());
                Buff.setRequiredChooseGreetingKey(updatedBuff.getRequiredChooseGreetingKey());
                Buff.setRequiredChangePassKey(updatedBuff.getRequiredChangePassKey());
                Buff.setRequiredRecordNameKey(updatedBuff.getRequiredRecordNameKey());
                Buff.setRequiredRecordFileKey(updatedBuff.getRequiredRecordFileKey());
                Buff.setRequiredListenFileKey(updatedBuff.getRequiredListenFileKey());
                Buff.setRequiredSaveFileKey(updatedBuff.getRequiredSaveFileKey());
                Buff.setRequiredDeleteFileKey(updatedBuff.getRequiredDeleteFileKey());
                Buff.setRequiredUndeleteFileKey(updatedBuff.getRequiredUndeleteFileKey());
                Buff.setRequiredEMailKey(updatedBuff.getRequiredEMailKey());
                Buff.setRequiredPauseKey(updatedBuff.getRequiredPauseKey());
                Buff.setRequiredRestartKey(updatedBuff.getRequiredRestartKey());
                Buff.setRequiredFastForwardKey(updatedBuff.getRequiredFastForwardKey());
                Buff.setRequiredRewindKey(updatedBuff.getRequiredRewindKey());
                Buff.setRequiredSkipGreetKey(updatedBuff.getRequiredSkipGreetKey());
                Buff.setRequiredRecordSilenceThreshold(updatedBuff.getRequiredRecordSilenceThreshold());
                Buff.setRequiredRecordSilenceHits(updatedBuff.getRequiredRecordSilenceHits());
                Buff.setRequiredWebTemplateFile(updatedBuff.getRequiredWebTemplateFile());
                Buff.setRequiredRecordSampleRate(updatedBuff.getRequiredRecordSampleRate());
                Buff.setRequiredOperatorExtension(updatedBuff.getRequiredOperatorExtension());
                Buff.setRequiredVMainExtension(updatedBuff.getRequiredVMainExtension());
                Buff.setRequiredVMailKey(updatedBuff.getRequiredVMailKey());
                Buff.setRequiredAutoPlaybackRecordings(updatedBuff.getRequiredAutoPlaybackRecordings());
                Buff.setRequiredStorageDir(updatedBuff.getRequiredStorageDir());
                Buff.setOptionalOdbcDSN(updatedBuff.getOptionalOdbcDSN());
                Buff.setOptionalRecordComent(updatedBuff.getOptionalRecordComent());
                Buff.setOptionalRecordTitle(updatedBuff.getOptionalRecordTitle());
                Buff.setOptionalRecordCopyright(updatedBuff.getOptionalRecordCopyright());
                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;
            }
        }
    }

    public void deleteFSSFVMail(CFFswAuthorization Authorization, CFFswFSSFVMailBuff Buff) {
        final String S_ProcName = "deleteFSSFVMail";
        ResultSet resultSet = null;
        try {
            Connection cnx = schema.getCnx();
            long TenantId = Buff.getRequiredTenantId();
            long FSSFVMailId = Buff.getRequiredFSSFVMailId();

            String sql = "call " + schema.getLowerDbSchemaName() + ".sp_delete_fssfvm( ?, ?, ?, ?, ?" + ", " + "?"
                    + ", " + "?" + ", " + "?" + " )";
            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++, TenantId);
            stmtDeleteByPKey.setLong(argIdx++, FSSFVMailId);
            stmtDeleteByPKey.setInt(argIdx++, Buff.getRequiredRevision());
            ;
            stmtDeleteByPKey.executeUpdate();
        } 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 deleteFSSFVMailByIdIdx(CFFswAuthorization Authorization, long argTenantId, long argFSSFVMailId) {
        final String S_ProcName = "deleteFSSFVMailByIdIdx";
        ResultSet resultSet = null;
        try {
            Connection cnx = schema.getCnx();
            String sql = "call " + schema.getLowerDbSchemaName() + ".sp_delete_fssfvm_by_ididx( ?, ?, ?, ?, ?"
                    + ", " + "?" + ", " + "?" + " )";
            if (stmtDeleteByIdIdx == null) {
                stmtDeleteByIdIdx = cnx.prepareStatement(sql);
            }
            int argIdx = 1;
            stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtDeleteByIdIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecUserId().toString());
            stmtDeleteByIdIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
            stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
            stmtDeleteByIdIdx.setLong(argIdx++, argTenantId);
            stmtDeleteByIdIdx.setLong(argIdx++, argFSSFVMailId);
            stmtDeleteByIdIdx.executeUpdate();
        } 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 deleteFSSFVMailByIdIdx(CFFswAuthorization Authorization, CFFswFSSFVMailPKey argKey) {
        deleteFSSFVMailByIdIdx(Authorization, argKey.getRequiredTenantId(), argKey.getRequiredFSSFVMailId());
    }

    public void deleteFSSFVMailByTenantIdx(CFFswAuthorization Authorization, long argTenantId) {
        final String S_ProcName = "deleteFSSFVMailByTenantIdx";
        ResultSet resultSet = null;
        try {
            Connection cnx = schema.getCnx();
            String sql = "call " + schema.getLowerDbSchemaName() + ".sp_delete_fssfvm_by_tenantidx( ?, ?, ?, ?, ?"
                    + ", " + "?" + " )";
            if (stmtDeleteByTenantIdx == null) {
                stmtDeleteByTenantIdx = cnx.prepareStatement(sql);
            }
            int argIdx = 1;
            stmtDeleteByTenantIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtDeleteByTenantIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecUserId().toString());
            stmtDeleteByTenantIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
            stmtDeleteByTenantIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtDeleteByTenantIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
            stmtDeleteByTenantIdx.setLong(argIdx++, argTenantId);
            stmtDeleteByTenantIdx.executeUpdate();
        } 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 deleteFSSFVMailByTenantIdx(CFFswAuthorization Authorization, CFFswFSSFVMailByTenantIdxKey argKey) {
        deleteFSSFVMailByTenantIdx(Authorization, argKey.getRequiredTenantId());
    }

    public void deleteFSSFVMailBySofiaIdx(CFFswAuthorization Authorization, long argTenantId, long argFSSofiaId) {
        final String S_ProcName = "deleteFSSFVMailBySofiaIdx";
        ResultSet resultSet = null;
        try {
            Connection cnx = schema.getCnx();
            String sql = "call " + schema.getLowerDbSchemaName() + ".sp_delete_fssfvm_by_sofiaidx( ?, ?, ?, ?, ?"
                    + ", " + "?" + ", " + "?" + " )";
            if (stmtDeleteBySofiaIdx == null) {
                stmtDeleteBySofiaIdx = cnx.prepareStatement(sql);
            }
            int argIdx = 1;
            stmtDeleteBySofiaIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtDeleteBySofiaIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecUserId().toString());
            stmtDeleteBySofiaIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
            stmtDeleteBySofiaIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtDeleteBySofiaIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
            stmtDeleteBySofiaIdx.setLong(argIdx++, argTenantId);
            stmtDeleteBySofiaIdx.setLong(argIdx++, argFSSofiaId);
            stmtDeleteBySofiaIdx.executeUpdate();
        } 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 deleteFSSFVMailBySofiaIdx(CFFswAuthorization Authorization, CFFswFSSFVMailBySofiaIdxKey argKey) {
        deleteFSSFVMailBySofiaIdx(Authorization, argKey.getRequiredTenantId(), argKey.getRequiredFSSofiaId());
    }

    public void deleteFSSFVMailByUNameIdx(CFFswAuthorization Authorization, long argTenantId, long argFSSofiaId,
            String argName) {
        final String S_ProcName = "deleteFSSFVMailByUNameIdx";
        ResultSet resultSet = null;
        try {
            Connection cnx = schema.getCnx();
            String sql = "call " + schema.getLowerDbSchemaName() + ".sp_delete_fssfvm_by_unameidx( ?, ?, ?, ?, ?"
                    + ", " + "?" + ", " + "?" + ", " + "?" + " )";
            if (stmtDeleteByUNameIdx == null) {
                stmtDeleteByUNameIdx = cnx.prepareStatement(sql);
            }
            int argIdx = 1;
            stmtDeleteByUNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtDeleteByUNameIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecUserId().toString());
            stmtDeleteByUNameIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
            stmtDeleteByUNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtDeleteByUNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
            stmtDeleteByUNameIdx.setLong(argIdx++, argTenantId);
            stmtDeleteByUNameIdx.setLong(argIdx++, argFSSofiaId);
            stmtDeleteByUNameIdx.setString(argIdx++, argName);
            stmtDeleteByUNameIdx.executeUpdate();
        } 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 deleteFSSFVMailByUNameIdx(CFFswAuthorization Authorization, CFFswFSSFVMailByUNameIdxKey argKey) {
        deleteFSSFVMailByUNameIdx(Authorization, argKey.getRequiredTenantId(), argKey.getRequiredFSSofiaId(),
                argKey.getRequiredName());
    }

    public CFFswCursor openFSSFVMailCursorAll(CFFswAuthorization Authorization) {
        String sql = getSqlSelectFSSFVMailBuff()
                + ((schema.isSystemUser(Authorization)) ? ""
                        : (" WHERE fsvm.TenantId = " + Authorization.getSecTenantId()))
                + "ORDER BY " + "fsvm.TenantId ASC" + ", " + "fsvm.FSSFVMailId ASC";
        CFFswCursor cursor = new CFFswMySqlCursor(Authorization, schema, sql);
        return (cursor);
    }

    public CFFswCursor openFSSFVMailCursorByTenantIdx(CFFswAuthorization Authorization, long TenantId) {
        String sql = getSqlSelectFSSFVMailBuff() + "WHERE " + "fsvm.TenantId = " + Long.toString(TenantId) + " "
                + "ORDER BY " + "fsvm.TenantId ASC" + ", " + "fsvm.FSSFVMailId ASC";
        CFFswCursor cursor = new CFFswMySqlCursor(Authorization, schema, sql);
        return (cursor);
    }

    public CFFswCursor openFSSFVMailCursorBySofiaIdx(CFFswAuthorization Authorization, long TenantId,
            long FSSofiaId) {
        String sql = getSqlSelectFSSFVMailBuff() + "WHERE " + "fsvm.TenantId = " + Long.toString(TenantId) + " "
                + "AND " + "fsvm.FSSofiaId = " + Long.toString(FSSofiaId) + " " + "ORDER BY " + "fsvm.TenantId ASC"
                + ", " + "fsvm.FSSFVMailId ASC";
        CFFswCursor cursor = new CFFswMySqlCursor(Authorization, schema, sql);
        return (cursor);
    }

    public CFFswCursor openFSSFVMailCursorByUNameIdx(CFFswAuthorization Authorization, long TenantId,
            long FSSofiaId, String Name) {
        String sql = getSqlSelectFSSFVMailBuff() + "WHERE " + "fsvm.TenantId = " + Long.toString(TenantId) + " "
                + "AND " + "fsvm.FSSofiaId = " + Long.toString(FSSofiaId) + " " + "AND " + "fsvm.Name = "
                + CFFswMySqlSchema.getQuotedString(Name) + " " + "ORDER BY " + "fsvm.TenantId ASC" + ", "
                + "fsvm.FSSFVMailId ASC";
        CFFswCursor cursor = new CFFswMySqlCursor(Authorization, schema, sql);
        return (cursor);
    }

    public void closeFSSFVMailCursor(CFFswCursor Cursor) {
        try {
            Cursor.getResultSet().close();
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "closeFSSFVMailCursor", e);
        }
    }

    public CFFswFSSFVMailBuff nextFSSFVMailCursor(CFFswCursor Cursor) {
        final String S_ProcName = "nextFSSFVMailCursor";
        try {
            ResultSet resultSet = Cursor.getResultSet();
            if (!resultSet.next()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "No more results available");
            }
            CFFswFSSFVMailBuff buff = unpackFSSFVMailResultSetToBuff(resultSet);
            return (buff);
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
        }
    }

    public CFFswFSSFVMailBuff prevFSSFVMailCursor(CFFswCursor Cursor) {
        int targetRowIdx = (Cursor.getRowIdx() > 1) ? Cursor.getRowIdx() - 1 : 1;
        CFFswFSSFVMailBuff buff = null;
        if (Cursor.getRowIdx() >= targetRowIdx) {
            Cursor.reset();
        }
        while (Cursor.getRowIdx() < targetRowIdx) {
            buff = nextFSSFVMailCursor(Cursor);
        }
        return (buff);
    }

    public CFFswFSSFVMailBuff firstFSSFVMailCursor(CFFswCursor Cursor) {
        int targetRowIdx = 1;
        CFFswFSSFVMailBuff buff = null;
        Cursor.reset();
        while (Cursor.getRowIdx() < targetRowIdx) {
            buff = nextFSSFVMailCursor(Cursor);
        }
        return (buff);
    }

    public CFFswFSSFVMailBuff lastFSSFVMailCursor(CFFswCursor Cursor) {
        throw CFLib.getDefaultExceptionFactory().newNotImplementedYetException(getClass(), "lastFSSFVMailCursor");
    }

    public CFFswFSSFVMailBuff nthFSSFVMailCursor(CFFswCursor Cursor, int Idx) {
        int targetRowIdx = Idx;
        CFFswFSSFVMailBuff buff = null;
        if (Cursor.getRowIdx() >= targetRowIdx) {
            Cursor.reset();
        }
        while (Cursor.getRowIdx() < targetRowIdx) {
            buff = nextFSSFVMailCursor(Cursor);
        }
        return (buff);
    }

    /**
     *   Release the prepared statements.
     *   <p>
     *   When the schema changes connections, the prepared statements
     *   have to be released because they contain connection-specific
     *   information for most databases.
     */
    public void releasePreparedStatements() {
        S_sqlSelectFSSFVMailDistinctClassCode = null;
        S_sqlSelectFSSFVMailBuff = null;
        if (stmtReadBuffByPKey != null) {
            try {
                stmtReadBuffByPKey.close();
            } catch (SQLException e) {
            }
            stmtReadBuffByPKey = null;
        }
        if (stmtLockBuffByPKey != null) {
            try {
                stmtLockBuffByPKey.close();
            } catch (SQLException e) {
            }
            stmtLockBuffByPKey = null;
        }
        if (stmtCreateByPKey != null) {
            try {
                stmtCreateByPKey.close();
            } catch (SQLException e) {
            }
            stmtCreateByPKey = null;
        }
        if (stmtUpdateByPKey != null) {
            try {
                stmtUpdateByPKey.close();
            } catch (SQLException e) {
            }
            stmtUpdateByPKey = null;
        }
        if (stmtDeleteByPKey != null) {
            try {
                stmtDeleteByPKey.close();
            } catch (SQLException e) {
            }
            stmtDeleteByPKey = null;
        }
        if (stmtDeleteByIdIdx != null) {
            try {
                stmtDeleteByIdIdx.close();
            } catch (SQLException e) {
            }
            stmtDeleteByIdIdx = null;
        }
        if (stmtDeleteByTenantIdx != null) {
            try {
                stmtDeleteByTenantIdx.close();
            } catch (SQLException e) {
            }
            stmtDeleteByTenantIdx = null;
        }
        if (stmtDeleteBySofiaIdx != null) {
            try {
                stmtDeleteBySofiaIdx.close();
            } catch (SQLException e) {
            }
            stmtDeleteBySofiaIdx = null;
        }
        if (stmtDeleteByUNameIdx != null) {
            try {
                stmtDeleteByUNameIdx.close();
            } catch (SQLException e) {
            }
            stmtDeleteByUNameIdx = null;
        }
        if (stmtReadAllBuff != null) {
            try {
                stmtReadAllBuff.close();
            } catch (SQLException e) {
            }
            stmtReadAllBuff = null;
        }
        if (stmtReadBuffByIdIdx != null) {
            try {
                stmtReadBuffByIdIdx.close();
            } catch (SQLException e) {
            }
            stmtReadBuffByIdIdx = null;
        }
        if (stmtReadBuffByTenantIdx != null) {
            try {
                stmtReadBuffByTenantIdx.close();
            } catch (SQLException e) {
            }
            stmtReadBuffByTenantIdx = null;
        }
        if (stmtReadBuffBySofiaIdx != null) {
            try {
                stmtReadBuffBySofiaIdx.close();
            } catch (SQLException e) {
            }
            stmtReadBuffBySofiaIdx = null;
        }
        if (stmtReadBuffByUNameIdx != null) {
            try {
                stmtReadBuffByUNameIdx.close();
            } catch (SQLException e) {
            }
            stmtReadBuffByUNameIdx = null;
        }
    }
}