net.sourceforge.msscodefactory.v1_11.MSSBamRam.MSSBamRamTableTable.java Source code

Java tutorial

Introduction

Here is the source code for net.sourceforge.msscodefactory.v1_11.MSSBamRam.MSSBamRamTableTable.java

Source

// Description: Java6 in-memory RAM DbIO implementation for Table.

/*
 *   MSS Code Factory 1.11
 *
 *   Copyright (c) 2012-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/>.
 *   
 * ***********************************************************************
 *
 *   $Revision$
 */

package net.sourceforge.msscodefactory.v1_11.MSSBamRam;

import java.sql.*;
import java.util.*;
import net.sourceforge.msscodefactory.cflib.v1_11.CFLib.*;
import org.apache.commons.codec.binary.Base64;
import net.sourceforge.msscodefactory.v1_11.MSSBam.*;
import net.sourceforge.msscodefactory.v1_11.MSSBamBL.*;
import net.sourceforge.msscodefactory.v1_11.MSSBamBLRam.*;

/*
 *   MSSBamRamTableTable in-memory RAM DbIO implementation
 *   for Table.
 */
public class MSSBamRamTableTable implements IMSSBamTableTable {
    private MSSBamBLRamSchema schema;
    private Map<MSSBamAnyObjPKey, MSSBamTableBuff> dictByPKey = new HashMap<MSSBamAnyObjPKey, MSSBamTableBuff>();
    private SortedMap<MSSBamTableBySchemaIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>> dictBySchemaIdx = new TreeMap<MSSBamTableBySchemaIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>>();
    private SortedMap<MSSBamTableBySchemaCdIdxKey, MSSBamTableBuff> dictBySchemaCdIdx = new TreeMap<MSSBamTableBySchemaCdIdxKey, MSSBamTableBuff>();
    private SortedMap<MSSBamTableByPrimaryIndexIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>> dictByPrimaryIndexIdx = new TreeMap<MSSBamTableByPrimaryIndexIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>>();
    private SortedMap<MSSBamTableByLookupIndexIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>> dictByLookupIndexIdx = new TreeMap<MSSBamTableByLookupIndexIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>>();
    private SortedMap<MSSBamTableByAltIndexIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>> dictByAltIndexIdx = new TreeMap<MSSBamTableByAltIndexIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>>();
    private SortedMap<MSSBamTableByQualTableIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>> dictByQualTableIdx = new TreeMap<MSSBamTableByQualTableIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>>();
    private SortedMap<MSSBamTableByLoadBehaveIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>> dictByLoadBehaveIdx = new TreeMap<MSSBamTableByLoadBehaveIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>>();
    private SortedMap<MSSBamTableByDataScopeIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>> dictByDataScopeIdx = new TreeMap<MSSBamTableByDataScopeIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>>();
    private SortedMap<MSSBamTableBySecScopeIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>> dictBySecScopeIdx = new TreeMap<MSSBamTableBySecScopeIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>>();
    private SortedMap<MSSBamTableByVAccSecIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>> dictByVAccSecIdx = new TreeMap<MSSBamTableByVAccSecIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>>();
    private SortedMap<MSSBamTableByVAccFreqIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>> dictByVAccFreqIdx = new TreeMap<MSSBamTableByVAccFreqIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>>();
    private SortedMap<MSSBamTableByEAccSecIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>> dictByEAccSecIdx = new TreeMap<MSSBamTableByEAccSecIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>>();
    private SortedMap<MSSBamTableByEAccFreqIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>> dictByEAccFreqIdx = new TreeMap<MSSBamTableByEAccFreqIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>>();

    public MSSBamRamTableTable(MSSBamBLRamSchema argSchema) {
        schema = argSchema;
    }

    public void createTable(MSSBamAuthorization Authorization, MSSBamTableBuff Buff) {
        MSSBamAnyObjPKey pkey = schema.getFactoryAnyObj().newPKey();

        pkey.setClassCode(Buff.getClassCode());

        pkey.setRequiredId(Buff.getRequiredId());

        MSSBamTableBySchemaIdxKey keySchemaIdx = schema.getFactoryTable().newSchemaIdxKey();
        keySchemaIdx.setRequiredSchemaId(Buff.getRequiredSchemaId());

        MSSBamTableBySchemaCdIdxKey keySchemaCdIdx = schema.getFactoryTable().newSchemaCdIdxKey();
        keySchemaCdIdx.setRequiredSchemaId(Buff.getRequiredSchemaId());
        keySchemaCdIdx.setRequiredTableClassCode(Buff.getRequiredTableClassCode());

        MSSBamTableByPrimaryIndexIdxKey keyPrimaryIndexIdx = schema.getFactoryTable().newPrimaryIndexIdxKey();
        keyPrimaryIndexIdx.setOptionalPrimaryIndexId(Buff.getOptionalPrimaryIndexId());

        MSSBamTableByLookupIndexIdxKey keyLookupIndexIdx = schema.getFactoryTable().newLookupIndexIdxKey();
        keyLookupIndexIdx.setOptionalLookupIndexId(Buff.getOptionalLookupIndexId());

        MSSBamTableByAltIndexIdxKey keyAltIndexIdx = schema.getFactoryTable().newAltIndexIdxKey();
        keyAltIndexIdx.setOptionalAltIndexId(Buff.getOptionalAltIndexId());

        MSSBamTableByQualTableIdxKey keyQualTableIdx = schema.getFactoryTable().newQualTableIdxKey();
        keyQualTableIdx.setOptionalQualifyingTableId(Buff.getOptionalQualifyingTableId());

        MSSBamTableByLoadBehaveIdxKey keyLoadBehaveIdx = schema.getFactoryTable().newLoadBehaveIdxKey();
        keyLoadBehaveIdx.setRequiredLoaderBehaviourId(Buff.getRequiredLoaderBehaviourId());

        MSSBamTableByDataScopeIdxKey keyDataScopeIdx = schema.getFactoryTable().newDataScopeIdxKey();
        keyDataScopeIdx.setOptionalDataScopeId(Buff.getOptionalDataScopeId());

        MSSBamTableBySecScopeIdxKey keySecScopeIdx = schema.getFactoryTable().newSecScopeIdxKey();
        keySecScopeIdx.setRequiredSecurityScopeId(Buff.getRequiredSecurityScopeId());

        MSSBamTableByVAccSecIdxKey keyVAccSecIdx = schema.getFactoryTable().newVAccSecIdxKey();
        keyVAccSecIdx.setOptionalViewAccessSecurityId(Buff.getOptionalViewAccessSecurityId());

        MSSBamTableByVAccFreqIdxKey keyVAccFreqIdx = schema.getFactoryTable().newVAccFreqIdxKey();
        keyVAccFreqIdx.setOptionalViewAccessFrequencyId(Buff.getOptionalViewAccessFrequencyId());

        MSSBamTableByEAccSecIdxKey keyEAccSecIdx = schema.getFactoryTable().newEAccSecIdxKey();
        keyEAccSecIdx.setOptionalEditAccessSecurityId(Buff.getOptionalEditAccessSecurityId());

        MSSBamTableByEAccFreqIdxKey keyEAccFreqIdx = schema.getFactoryTable().newEAccFreqIdxKey();
        keyEAccFreqIdx.setOptionalEditAccessFrequencyId(Buff.getOptionalEditAccessFrequencyId());

        // Validate unique indexes

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

        if (dictBySchemaCdIdx.containsKey(keySchemaCdIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "createTable",
                    "TableSchemaCodeIdx", keySchemaCdIdx);
        }

        // Validate foreign keys

        {
            boolean allNull = true;
            allNull = false;
            if (!allNull) {
                if (null == schema.getTableScope().readDerivedByIdIdx(Authorization, Buff.getRequiredId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "createTable", "Superclass", "SuperClass", "Scope", null);
                }
            }
        }

        {
            boolean allNull = true;
            allNull = false;
            if (!allNull) {
                if (null == schema.getTableSchemaDef().readDerivedByIdIdx(Authorization,
                        Buff.getRequiredSchemaId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "createTable", "Container", "Schema", "SchemaDef", null);
                }
            }
        }

        {
            boolean allNull = true;
            allNull = false;
            if (!allNull) {
                if (null == schema.getTableLoaderBehaviour().readDerivedByIdIdx(Authorization,
                        Buff.getRequiredLoaderBehaviourId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "createTable", "Lookup", "LoaderBehaviour", "LoaderBehaviour", null);
                }
            }
        }

        {
            boolean allNull = true;
            allNull = false;
            if (!allNull) {
                if (null == schema.getTableSecurityScope().readDerivedByIdIdx(Authorization,
                        Buff.getRequiredSecurityScopeId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "createTable", "Lookup", "SecurityScope", "SecurityScope", null);
                }
            }
        }

        // Proceed with adding the new record

        dictByPKey.put(pkey, Buff);

        SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictSchemaIdx;
        if (dictBySchemaIdx.containsKey(keySchemaIdx)) {
            subdictSchemaIdx = dictBySchemaIdx.get(keySchemaIdx);
        } else {
            subdictSchemaIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>();
            dictBySchemaIdx.put(keySchemaIdx, subdictSchemaIdx);
        }
        subdictSchemaIdx.put(pkey, Buff);

        dictBySchemaCdIdx.put(keySchemaCdIdx, Buff);

        SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictPrimaryIndexIdx;
        if (dictByPrimaryIndexIdx.containsKey(keyPrimaryIndexIdx)) {
            subdictPrimaryIndexIdx = dictByPrimaryIndexIdx.get(keyPrimaryIndexIdx);
        } else {
            subdictPrimaryIndexIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>();
            dictByPrimaryIndexIdx.put(keyPrimaryIndexIdx, subdictPrimaryIndexIdx);
        }
        subdictPrimaryIndexIdx.put(pkey, Buff);

        SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictLookupIndexIdx;
        if (dictByLookupIndexIdx.containsKey(keyLookupIndexIdx)) {
            subdictLookupIndexIdx = dictByLookupIndexIdx.get(keyLookupIndexIdx);
        } else {
            subdictLookupIndexIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>();
            dictByLookupIndexIdx.put(keyLookupIndexIdx, subdictLookupIndexIdx);
        }
        subdictLookupIndexIdx.put(pkey, Buff);

        SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictAltIndexIdx;
        if (dictByAltIndexIdx.containsKey(keyAltIndexIdx)) {
            subdictAltIndexIdx = dictByAltIndexIdx.get(keyAltIndexIdx);
        } else {
            subdictAltIndexIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>();
            dictByAltIndexIdx.put(keyAltIndexIdx, subdictAltIndexIdx);
        }
        subdictAltIndexIdx.put(pkey, Buff);

        SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictQualTableIdx;
        if (dictByQualTableIdx.containsKey(keyQualTableIdx)) {
            subdictQualTableIdx = dictByQualTableIdx.get(keyQualTableIdx);
        } else {
            subdictQualTableIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>();
            dictByQualTableIdx.put(keyQualTableIdx, subdictQualTableIdx);
        }
        subdictQualTableIdx.put(pkey, Buff);

        SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictLoadBehaveIdx;
        if (dictByLoadBehaveIdx.containsKey(keyLoadBehaveIdx)) {
            subdictLoadBehaveIdx = dictByLoadBehaveIdx.get(keyLoadBehaveIdx);
        } else {
            subdictLoadBehaveIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>();
            dictByLoadBehaveIdx.put(keyLoadBehaveIdx, subdictLoadBehaveIdx);
        }
        subdictLoadBehaveIdx.put(pkey, Buff);

        SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictDataScopeIdx;
        if (dictByDataScopeIdx.containsKey(keyDataScopeIdx)) {
            subdictDataScopeIdx = dictByDataScopeIdx.get(keyDataScopeIdx);
        } else {
            subdictDataScopeIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>();
            dictByDataScopeIdx.put(keyDataScopeIdx, subdictDataScopeIdx);
        }
        subdictDataScopeIdx.put(pkey, Buff);

        SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictSecScopeIdx;
        if (dictBySecScopeIdx.containsKey(keySecScopeIdx)) {
            subdictSecScopeIdx = dictBySecScopeIdx.get(keySecScopeIdx);
        } else {
            subdictSecScopeIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>();
            dictBySecScopeIdx.put(keySecScopeIdx, subdictSecScopeIdx);
        }
        subdictSecScopeIdx.put(pkey, Buff);

        SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictVAccSecIdx;
        if (dictByVAccSecIdx.containsKey(keyVAccSecIdx)) {
            subdictVAccSecIdx = dictByVAccSecIdx.get(keyVAccSecIdx);
        } else {
            subdictVAccSecIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>();
            dictByVAccSecIdx.put(keyVAccSecIdx, subdictVAccSecIdx);
        }
        subdictVAccSecIdx.put(pkey, Buff);

        SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictVAccFreqIdx;
        if (dictByVAccFreqIdx.containsKey(keyVAccFreqIdx)) {
            subdictVAccFreqIdx = dictByVAccFreqIdx.get(keyVAccFreqIdx);
        } else {
            subdictVAccFreqIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>();
            dictByVAccFreqIdx.put(keyVAccFreqIdx, subdictVAccFreqIdx);
        }
        subdictVAccFreqIdx.put(pkey, Buff);

        SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictEAccSecIdx;
        if (dictByEAccSecIdx.containsKey(keyEAccSecIdx)) {
            subdictEAccSecIdx = dictByEAccSecIdx.get(keyEAccSecIdx);
        } else {
            subdictEAccSecIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>();
            dictByEAccSecIdx.put(keyEAccSecIdx, subdictEAccSecIdx);
        }
        subdictEAccSecIdx.put(pkey, Buff);

        SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictEAccFreqIdx;
        if (dictByEAccFreqIdx.containsKey(keyEAccFreqIdx)) {
            subdictEAccFreqIdx = dictByEAccFreqIdx.get(keyEAccFreqIdx);
        } else {
            subdictEAccFreqIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>();
            dictByEAccFreqIdx.put(keyEAccFreqIdx, subdictEAccFreqIdx);
        }
        subdictEAccFreqIdx.put(pkey, Buff);

    }

    public MSSBamTableBuff readDerived(MSSBamAuthorization Authorization, MSSBamAnyObjPKey PKey) {
        final String S_ProcName = "MSSBamRamTable.readDerived() ";
        MSSBamAnyObjPKey key = schema.getFactoryAnyObj().newPKey();
        key.setRequiredId(PKey.getRequiredId());
        MSSBamTableBuff buff;
        if (dictByPKey.containsKey(key)) {
            buff = dictByPKey.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

    public MSSBamTableBuff lockDerived(MSSBamAuthorization Authorization, MSSBamAnyObjPKey PKey) {
        final String S_ProcName = "MSSBamRamTable.readDerived() ";
        MSSBamAnyObjPKey key = schema.getFactoryAnyObj().newPKey();
        key.setRequiredId(PKey.getRequiredId());
        MSSBamTableBuff buff;
        if (dictByPKey.containsKey(key)) {
            buff = dictByPKey.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

    public MSSBamTableBuff[] readAllDerived(MSSBamAuthorization Authorization) {
        final String S_ProcName = "MSSBamRamTable.readAllDerived() ";
        MSSBamTableBuff[] retList = new MSSBamTableBuff[dictByPKey.values().size()];
        Iterator<MSSBamTableBuff> iter = dictByPKey.values().iterator();
        int idx = 0;
        while (iter.hasNext()) {
            retList[idx++] = iter.next();
        }
        return (retList);
    }

    public MSSBamTableBuff[] readDerivedByTenantIdx(MSSBamAuthorization Authorization, long TenantId) {
        final String S_ProcName = "MSSBamRamAnyObj.readDerivedByTenantIdx() ";
        MSSBamAnyObjBuff buffList[] = schema.getTableAnyObj().readDerivedByTenantIdx(Authorization, TenantId);
        if (buffList == null) {
            return (null);
        } else {
            MSSBamAnyObjBuff buff;
            ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>();
            for (int idx = 0; idx < buffList.length; idx++) {
                buff = buffList[idx];
                if ((buff != null) && (buff instanceof MSSBamTableBuff)) {
                    filteredList.add((MSSBamTableBuff) buff);
                }
            }
            return (filteredList.toArray(new MSSBamTableBuff[0]));
        }
    }

    public MSSBamTableBuff[] readDerivedByScopeIdx(MSSBamAuthorization Authorization, Long ScopeId) {
        final String S_ProcName = "MSSBamRamAnyObj.readDerivedByScopeIdx() ";
        MSSBamAnyObjBuff buffList[] = schema.getTableAnyObj().readDerivedByScopeIdx(Authorization, ScopeId);
        if (buffList == null) {
            return (null);
        } else {
            MSSBamAnyObjBuff buff;
            ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>();
            for (int idx = 0; idx < buffList.length; idx++) {
                buff = buffList[idx];
                if ((buff != null) && (buff instanceof MSSBamTableBuff)) {
                    filteredList.add((MSSBamTableBuff) buff);
                }
            }
            return (filteredList.toArray(new MSSBamTableBuff[0]));
        }
    }

    public MSSBamTableBuff[] readDerivedByDefSchemaIdx(MSSBamAuthorization Authorization, Long DefSchemaId) {
        final String S_ProcName = "MSSBamRamAnyObj.readDerivedByDefSchemaIdx() ";
        MSSBamAnyObjBuff buffList[] = schema.getTableAnyObj().readDerivedByDefSchemaIdx(Authorization, DefSchemaId);
        if (buffList == null) {
            return (null);
        } else {
            MSSBamAnyObjBuff buff;
            ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>();
            for (int idx = 0; idx < buffList.length; idx++) {
                buff = buffList[idx];
                if ((buff != null) && (buff instanceof MSSBamTableBuff)) {
                    filteredList.add((MSSBamTableBuff) buff);
                }
            }
            return (filteredList.toArray(new MSSBamTableBuff[0]));
        }
    }

    public MSSBamTableBuff[] readDerivedByAuthorIdx(MSSBamAuthorization Authorization, Long AuthorId) {
        final String S_ProcName = "MSSBamRamAnyObj.readDerivedByAuthorIdx() ";
        MSSBamAnyObjBuff buffList[] = schema.getTableAnyObj().readDerivedByAuthorIdx(Authorization, AuthorId);
        if (buffList == null) {
            return (null);
        } else {
            MSSBamAnyObjBuff buff;
            ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>();
            for (int idx = 0; idx < buffList.length; idx++) {
                buff = buffList[idx];
                if ((buff != null) && (buff instanceof MSSBamTableBuff)) {
                    filteredList.add((MSSBamTableBuff) buff);
                }
            }
            return (filteredList.toArray(new MSSBamTableBuff[0]));
        }
    }

    public MSSBamTableBuff readDerivedByUNameIdx(MSSBamAuthorization Authorization, Long ScopeId, String Name) {
        final String S_ProcName = "MSSBamRamAnyObj.readDerivedByUNameIdx() ";
        MSSBamAnyObjBuff buff = schema.getTableAnyObj().readDerivedByUNameIdx(Authorization, ScopeId, Name);
        if (buff == null) {
            return (null);
        } else if (buff instanceof MSSBamTableBuff) {
            return ((MSSBamTableBuff) buff);
        } else {
            return (null);
        }
    }

    public MSSBamTableBuff[] readDerivedBySchemaIdx(MSSBamAuthorization Authorization, long SchemaId) {
        final String S_ProcName = "MSSBamRamTable.readDerivedBySchemaIdx() ";
        MSSBamTableBySchemaIdxKey key = schema.getFactoryTable().newSchemaIdxKey();
        key.setRequiredSchemaId(SchemaId);

        MSSBamTableBuff[] recArray;
        if (dictBySchemaIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictSchemaIdx = dictBySchemaIdx.get(key);
            recArray = new MSSBamTableBuff[subdictSchemaIdx.size()];
            Iterator<MSSBamTableBuff> iter = subdictSchemaIdx.values().iterator();
            int idx = 0;
            while (iter.hasNext()) {
                recArray[idx++] = iter.next();
            }
        } else {
            recArray = new MSSBamTableBuff[0];
        }
        return (recArray);
    }

    public MSSBamTableBuff readDerivedBySchemaCdIdx(MSSBamAuthorization Authorization, long SchemaId,
            String TableClassCode) {
        final String S_ProcName = "MSSBamRamTable.readDerivedBySchemaCdIdx() ";
        MSSBamTableBySchemaCdIdxKey key = schema.getFactoryTable().newSchemaCdIdxKey();
        key.setRequiredSchemaId(SchemaId);
        key.setRequiredTableClassCode(TableClassCode);

        MSSBamTableBuff buff;
        if (dictBySchemaCdIdx.containsKey(key)) {
            buff = dictBySchemaCdIdx.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

    public MSSBamTableBuff[] readDerivedByPrimaryIndexIdx(MSSBamAuthorization Authorization, Long PrimaryIndexId) {
        final String S_ProcName = "MSSBamRamTable.readDerivedByPrimaryIndexIdx() ";
        MSSBamTableByPrimaryIndexIdxKey key = schema.getFactoryTable().newPrimaryIndexIdxKey();
        key.setOptionalPrimaryIndexId(PrimaryIndexId);

        MSSBamTableBuff[] recArray;
        if (dictByPrimaryIndexIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictPrimaryIndexIdx = dictByPrimaryIndexIdx.get(key);
            recArray = new MSSBamTableBuff[subdictPrimaryIndexIdx.size()];
            Iterator<MSSBamTableBuff> iter = subdictPrimaryIndexIdx.values().iterator();
            int idx = 0;
            while (iter.hasNext()) {
                recArray[idx++] = iter.next();
            }
        } else {
            recArray = new MSSBamTableBuff[0];
        }
        return (recArray);
    }

    public MSSBamTableBuff[] readDerivedByLookupIndexIdx(MSSBamAuthorization Authorization, Long LookupIndexId) {
        final String S_ProcName = "MSSBamRamTable.readDerivedByLookupIndexIdx() ";
        MSSBamTableByLookupIndexIdxKey key = schema.getFactoryTable().newLookupIndexIdxKey();
        key.setOptionalLookupIndexId(LookupIndexId);

        MSSBamTableBuff[] recArray;
        if (dictByLookupIndexIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictLookupIndexIdx = dictByLookupIndexIdx.get(key);
            recArray = new MSSBamTableBuff[subdictLookupIndexIdx.size()];
            Iterator<MSSBamTableBuff> iter = subdictLookupIndexIdx.values().iterator();
            int idx = 0;
            while (iter.hasNext()) {
                recArray[idx++] = iter.next();
            }
        } else {
            recArray = new MSSBamTableBuff[0];
        }
        return (recArray);
    }

    public MSSBamTableBuff[] readDerivedByAltIndexIdx(MSSBamAuthorization Authorization, Long AltIndexId) {
        final String S_ProcName = "MSSBamRamTable.readDerivedByAltIndexIdx() ";
        MSSBamTableByAltIndexIdxKey key = schema.getFactoryTable().newAltIndexIdxKey();
        key.setOptionalAltIndexId(AltIndexId);

        MSSBamTableBuff[] recArray;
        if (dictByAltIndexIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictAltIndexIdx = dictByAltIndexIdx.get(key);
            recArray = new MSSBamTableBuff[subdictAltIndexIdx.size()];
            Iterator<MSSBamTableBuff> iter = subdictAltIndexIdx.values().iterator();
            int idx = 0;
            while (iter.hasNext()) {
                recArray[idx++] = iter.next();
            }
        } else {
            recArray = new MSSBamTableBuff[0];
        }
        return (recArray);
    }

    public MSSBamTableBuff[] readDerivedByQualTableIdx(MSSBamAuthorization Authorization, Long QualifyingTableId) {
        final String S_ProcName = "MSSBamRamTable.readDerivedByQualTableIdx() ";
        MSSBamTableByQualTableIdxKey key = schema.getFactoryTable().newQualTableIdxKey();
        key.setOptionalQualifyingTableId(QualifyingTableId);

        MSSBamTableBuff[] recArray;
        if (dictByQualTableIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictQualTableIdx = dictByQualTableIdx.get(key);
            recArray = new MSSBamTableBuff[subdictQualTableIdx.size()];
            Iterator<MSSBamTableBuff> iter = subdictQualTableIdx.values().iterator();
            int idx = 0;
            while (iter.hasNext()) {
                recArray[idx++] = iter.next();
            }
        } else {
            recArray = new MSSBamTableBuff[0];
        }
        return (recArray);
    }

    public MSSBamTableBuff[] readDerivedByLoadBehaveIdx(MSSBamAuthorization Authorization,
            short LoaderBehaviourId) {
        final String S_ProcName = "MSSBamRamTable.readDerivedByLoadBehaveIdx() ";
        MSSBamTableByLoadBehaveIdxKey key = schema.getFactoryTable().newLoadBehaveIdxKey();
        key.setRequiredLoaderBehaviourId(LoaderBehaviourId);

        MSSBamTableBuff[] recArray;
        if (dictByLoadBehaveIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictLoadBehaveIdx = dictByLoadBehaveIdx.get(key);
            recArray = new MSSBamTableBuff[subdictLoadBehaveIdx.size()];
            Iterator<MSSBamTableBuff> iter = subdictLoadBehaveIdx.values().iterator();
            int idx = 0;
            while (iter.hasNext()) {
                recArray[idx++] = iter.next();
            }
        } else {
            recArray = new MSSBamTableBuff[0];
        }
        return (recArray);
    }

    public MSSBamTableBuff[] readDerivedByDataScopeIdx(MSSBamAuthorization Authorization, Short DataScopeId) {
        final String S_ProcName = "MSSBamRamTable.readDerivedByDataScopeIdx() ";
        MSSBamTableByDataScopeIdxKey key = schema.getFactoryTable().newDataScopeIdxKey();
        key.setOptionalDataScopeId(DataScopeId);

        MSSBamTableBuff[] recArray;
        if (dictByDataScopeIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictDataScopeIdx = dictByDataScopeIdx.get(key);
            recArray = new MSSBamTableBuff[subdictDataScopeIdx.size()];
            Iterator<MSSBamTableBuff> iter = subdictDataScopeIdx.values().iterator();
            int idx = 0;
            while (iter.hasNext()) {
                recArray[idx++] = iter.next();
            }
        } else {
            recArray = new MSSBamTableBuff[0];
        }
        return (recArray);
    }

    public MSSBamTableBuff[] readDerivedBySecScopeIdx(MSSBamAuthorization Authorization, short SecurityScopeId) {
        final String S_ProcName = "MSSBamRamTable.readDerivedBySecScopeIdx() ";
        MSSBamTableBySecScopeIdxKey key = schema.getFactoryTable().newSecScopeIdxKey();
        key.setRequiredSecurityScopeId(SecurityScopeId);

        MSSBamTableBuff[] recArray;
        if (dictBySecScopeIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictSecScopeIdx = dictBySecScopeIdx.get(key);
            recArray = new MSSBamTableBuff[subdictSecScopeIdx.size()];
            Iterator<MSSBamTableBuff> iter = subdictSecScopeIdx.values().iterator();
            int idx = 0;
            while (iter.hasNext()) {
                recArray[idx++] = iter.next();
            }
        } else {
            recArray = new MSSBamTableBuff[0];
        }
        return (recArray);
    }

    public MSSBamTableBuff[] readDerivedByVAccSecIdx(MSSBamAuthorization Authorization,
            Short ViewAccessSecurityId) {
        final String S_ProcName = "MSSBamRamTable.readDerivedByVAccSecIdx() ";
        MSSBamTableByVAccSecIdxKey key = schema.getFactoryTable().newVAccSecIdxKey();
        key.setOptionalViewAccessSecurityId(ViewAccessSecurityId);

        MSSBamTableBuff[] recArray;
        if (dictByVAccSecIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictVAccSecIdx = dictByVAccSecIdx.get(key);
            recArray = new MSSBamTableBuff[subdictVAccSecIdx.size()];
            Iterator<MSSBamTableBuff> iter = subdictVAccSecIdx.values().iterator();
            int idx = 0;
            while (iter.hasNext()) {
                recArray[idx++] = iter.next();
            }
        } else {
            recArray = new MSSBamTableBuff[0];
        }
        return (recArray);
    }

    public MSSBamTableBuff[] readDerivedByVAccFreqIdx(MSSBamAuthorization Authorization,
            Short ViewAccessFrequencyId) {
        final String S_ProcName = "MSSBamRamTable.readDerivedByVAccFreqIdx() ";
        MSSBamTableByVAccFreqIdxKey key = schema.getFactoryTable().newVAccFreqIdxKey();
        key.setOptionalViewAccessFrequencyId(ViewAccessFrequencyId);

        MSSBamTableBuff[] recArray;
        if (dictByVAccFreqIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictVAccFreqIdx = dictByVAccFreqIdx.get(key);
            recArray = new MSSBamTableBuff[subdictVAccFreqIdx.size()];
            Iterator<MSSBamTableBuff> iter = subdictVAccFreqIdx.values().iterator();
            int idx = 0;
            while (iter.hasNext()) {
                recArray[idx++] = iter.next();
            }
        } else {
            recArray = new MSSBamTableBuff[0];
        }
        return (recArray);
    }

    public MSSBamTableBuff[] readDerivedByEAccSecIdx(MSSBamAuthorization Authorization,
            Short EditAccessSecurityId) {
        final String S_ProcName = "MSSBamRamTable.readDerivedByEAccSecIdx() ";
        MSSBamTableByEAccSecIdxKey key = schema.getFactoryTable().newEAccSecIdxKey();
        key.setOptionalEditAccessSecurityId(EditAccessSecurityId);

        MSSBamTableBuff[] recArray;
        if (dictByEAccSecIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictEAccSecIdx = dictByEAccSecIdx.get(key);
            recArray = new MSSBamTableBuff[subdictEAccSecIdx.size()];
            Iterator<MSSBamTableBuff> iter = subdictEAccSecIdx.values().iterator();
            int idx = 0;
            while (iter.hasNext()) {
                recArray[idx++] = iter.next();
            }
        } else {
            recArray = new MSSBamTableBuff[0];
        }
        return (recArray);
    }

    public MSSBamTableBuff[] readDerivedByEAccFreqIdx(MSSBamAuthorization Authorization,
            Short EditAccessFrequencyId) {
        final String S_ProcName = "MSSBamRamTable.readDerivedByEAccFreqIdx() ";
        MSSBamTableByEAccFreqIdxKey key = schema.getFactoryTable().newEAccFreqIdxKey();
        key.setOptionalEditAccessFrequencyId(EditAccessFrequencyId);

        MSSBamTableBuff[] recArray;
        if (dictByEAccFreqIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictEAccFreqIdx = dictByEAccFreqIdx.get(key);
            recArray = new MSSBamTableBuff[subdictEAccFreqIdx.size()];
            Iterator<MSSBamTableBuff> iter = subdictEAccFreqIdx.values().iterator();
            int idx = 0;
            while (iter.hasNext()) {
                recArray[idx++] = iter.next();
            }
        } else {
            recArray = new MSSBamTableBuff[0];
        }
        return (recArray);
    }

    public MSSBamTableBuff readDerivedByIdIdx(MSSBamAuthorization Authorization, long Id) {
        final String S_ProcName = "MSSBamRamAnyObj.readDerivedByIdIdx() ";
        MSSBamAnyObjPKey key = schema.getFactoryAnyObj().newPKey();
        key.setRequiredId(Id);

        MSSBamTableBuff buff;
        if (dictByPKey.containsKey(key)) {
            buff = dictByPKey.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

    public MSSBamTableBuff readBuff(MSSBamAuthorization Authorization, MSSBamAnyObjPKey PKey) {
        final String S_ProcName = "MSSBamRamTable.readBuff() ";
        MSSBamTableBuff buff = readDerived(Authorization, PKey);
        if ((buff != null) && (!buff.getClassCode().equals("TBL"))) {
            buff = null;
        }
        return (buff);
    }

    public MSSBamTableBuff lockBuff(MSSBamAuthorization Authorization, MSSBamAnyObjPKey PKey) {
        final String S_ProcName = "MSSBamRamTable.readBuff() ";
        MSSBamTableBuff buff = readDerived(Authorization, PKey);
        if ((buff != null) && (!buff.getClassCode().equals("TBL"))) {
            buff = null;
        }
        return (buff);
    }

    public MSSBamTableBuff[] readAllBuff(MSSBamAuthorization Authorization) {
        final String S_ProcName = "MSSBamRamTable.readAllBuff() ";
        MSSBamTableBuff buff;
        ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>();
        MSSBamTableBuff[] buffList = readAllDerived(Authorization);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("TBL")) {
                filteredList.add(buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableBuff[0]));
    }

    public MSSBamTableBuff readBuffByIdIdx(MSSBamAuthorization Authorization, long Id) {
        final String S_ProcName = "MSSBamRamAnyObj.readBuffByIdIdx() ";
        MSSBamAnyObjBuff buff = readDerivedByIdIdx(Authorization, Id);
        if ((buff != null) && buff.getClassCode().equals("ANYO")) {
            return ((MSSBamTableBuff) buff);
        } else {
            return (null);
        }
    }

    public MSSBamTableBuff[] readBuffByTenantIdx(MSSBamAuthorization Authorization, long TenantId) {
        final String S_ProcName = "MSSBamRamAnyObj.readBuffByTenantIdx() ";
        MSSBamAnyObjBuff buff;
        ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>();
        MSSBamAnyObjBuff[] buffList = readDerivedByTenantIdx(Authorization, TenantId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("ANYO")) {
                filteredList.add((MSSBamTableBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableBuff[0]));
    }

    public MSSBamTableBuff[] readBuffByScopeIdx(MSSBamAuthorization Authorization, Long ScopeId) {
        final String S_ProcName = "MSSBamRamAnyObj.readBuffByScopeIdx() ";
        MSSBamAnyObjBuff buff;
        ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>();
        MSSBamAnyObjBuff[] buffList = readDerivedByScopeIdx(Authorization, ScopeId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("ANYO")) {
                filteredList.add((MSSBamTableBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableBuff[0]));
    }

    public MSSBamTableBuff[] readBuffByDefSchemaIdx(MSSBamAuthorization Authorization, Long DefSchemaId) {
        final String S_ProcName = "MSSBamRamAnyObj.readBuffByDefSchemaIdx() ";
        MSSBamAnyObjBuff buff;
        ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>();
        MSSBamAnyObjBuff[] buffList = readDerivedByDefSchemaIdx(Authorization, DefSchemaId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("ANYO")) {
                filteredList.add((MSSBamTableBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableBuff[0]));
    }

    public MSSBamTableBuff[] readBuffByAuthorIdx(MSSBamAuthorization Authorization, Long AuthorId) {
        final String S_ProcName = "MSSBamRamAnyObj.readBuffByAuthorIdx() ";
        MSSBamAnyObjBuff buff;
        ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>();
        MSSBamAnyObjBuff[] buffList = readDerivedByAuthorIdx(Authorization, AuthorId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("ANYO")) {
                filteredList.add((MSSBamTableBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableBuff[0]));
    }

    public MSSBamTableBuff readBuffByUNameIdx(MSSBamAuthorization Authorization, Long ScopeId, String Name) {
        final String S_ProcName = "MSSBamRamAnyObj.readBuffByUNameIdx() ";
        MSSBamAnyObjBuff buff = readDerivedByUNameIdx(Authorization, ScopeId, Name);
        if ((buff != null) && buff.getClassCode().equals("ANYO")) {
            return ((MSSBamTableBuff) buff);
        } else {
            return (null);
        }
    }

    public MSSBamTableBuff[] readBuffBySchemaIdx(MSSBamAuthorization Authorization, long SchemaId) {
        final String S_ProcName = "MSSBamRamTable.readBuffBySchemaIdx() ";
        MSSBamTableBuff buff;
        ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>();
        MSSBamTableBuff[] buffList = readDerivedBySchemaIdx(Authorization, SchemaId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("TBL")) {
                filteredList.add((MSSBamTableBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableBuff[0]));
    }

    public MSSBamTableBuff readBuffBySchemaCdIdx(MSSBamAuthorization Authorization, long SchemaId,
            String TableClassCode) {
        final String S_ProcName = "MSSBamRamTable.readBuffBySchemaCdIdx() ";
        MSSBamTableBuff buff = readDerivedBySchemaCdIdx(Authorization, SchemaId, TableClassCode);
        if ((buff != null) && buff.getClassCode().equals("TBL")) {
            return ((MSSBamTableBuff) buff);
        } else {
            return (null);
        }
    }

    public MSSBamTableBuff[] readBuffByPrimaryIndexIdx(MSSBamAuthorization Authorization, Long PrimaryIndexId) {
        final String S_ProcName = "MSSBamRamTable.readBuffByPrimaryIndexIdx() ";
        MSSBamTableBuff buff;
        ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>();
        MSSBamTableBuff[] buffList = readDerivedByPrimaryIndexIdx(Authorization, PrimaryIndexId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("TBL")) {
                filteredList.add((MSSBamTableBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableBuff[0]));
    }

    public MSSBamTableBuff[] readBuffByLookupIndexIdx(MSSBamAuthorization Authorization, Long LookupIndexId) {
        final String S_ProcName = "MSSBamRamTable.readBuffByLookupIndexIdx() ";
        MSSBamTableBuff buff;
        ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>();
        MSSBamTableBuff[] buffList = readDerivedByLookupIndexIdx(Authorization, LookupIndexId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("TBL")) {
                filteredList.add((MSSBamTableBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableBuff[0]));
    }

    public MSSBamTableBuff[] readBuffByAltIndexIdx(MSSBamAuthorization Authorization, Long AltIndexId) {
        final String S_ProcName = "MSSBamRamTable.readBuffByAltIndexIdx() ";
        MSSBamTableBuff buff;
        ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>();
        MSSBamTableBuff[] buffList = readDerivedByAltIndexIdx(Authorization, AltIndexId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("TBL")) {
                filteredList.add((MSSBamTableBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableBuff[0]));
    }

    public MSSBamTableBuff[] readBuffByQualTableIdx(MSSBamAuthorization Authorization, Long QualifyingTableId) {
        final String S_ProcName = "MSSBamRamTable.readBuffByQualTableIdx() ";
        MSSBamTableBuff buff;
        ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>();
        MSSBamTableBuff[] buffList = readDerivedByQualTableIdx(Authorization, QualifyingTableId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("TBL")) {
                filteredList.add((MSSBamTableBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableBuff[0]));
    }

    public MSSBamTableBuff[] readBuffByLoadBehaveIdx(MSSBamAuthorization Authorization, short LoaderBehaviourId) {
        final String S_ProcName = "MSSBamRamTable.readBuffByLoadBehaveIdx() ";
        MSSBamTableBuff buff;
        ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>();
        MSSBamTableBuff[] buffList = readDerivedByLoadBehaveIdx(Authorization, LoaderBehaviourId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("TBL")) {
                filteredList.add((MSSBamTableBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableBuff[0]));
    }

    public MSSBamTableBuff[] readBuffByDataScopeIdx(MSSBamAuthorization Authorization, Short DataScopeId) {
        final String S_ProcName = "MSSBamRamTable.readBuffByDataScopeIdx() ";
        MSSBamTableBuff buff;
        ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>();
        MSSBamTableBuff[] buffList = readDerivedByDataScopeIdx(Authorization, DataScopeId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("TBL")) {
                filteredList.add((MSSBamTableBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableBuff[0]));
    }

    public MSSBamTableBuff[] readBuffBySecScopeIdx(MSSBamAuthorization Authorization, short SecurityScopeId) {
        final String S_ProcName = "MSSBamRamTable.readBuffBySecScopeIdx() ";
        MSSBamTableBuff buff;
        ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>();
        MSSBamTableBuff[] buffList = readDerivedBySecScopeIdx(Authorization, SecurityScopeId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("TBL")) {
                filteredList.add((MSSBamTableBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableBuff[0]));
    }

    public MSSBamTableBuff[] readBuffByVAccSecIdx(MSSBamAuthorization Authorization, Short ViewAccessSecurityId) {
        final String S_ProcName = "MSSBamRamTable.readBuffByVAccSecIdx() ";
        MSSBamTableBuff buff;
        ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>();
        MSSBamTableBuff[] buffList = readDerivedByVAccSecIdx(Authorization, ViewAccessSecurityId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("TBL")) {
                filteredList.add((MSSBamTableBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableBuff[0]));
    }

    public MSSBamTableBuff[] readBuffByVAccFreqIdx(MSSBamAuthorization Authorization, Short ViewAccessFrequencyId) {
        final String S_ProcName = "MSSBamRamTable.readBuffByVAccFreqIdx() ";
        MSSBamTableBuff buff;
        ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>();
        MSSBamTableBuff[] buffList = readDerivedByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("TBL")) {
                filteredList.add((MSSBamTableBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableBuff[0]));
    }

    public MSSBamTableBuff[] readBuffByEAccSecIdx(MSSBamAuthorization Authorization, Short EditAccessSecurityId) {
        final String S_ProcName = "MSSBamRamTable.readBuffByEAccSecIdx() ";
        MSSBamTableBuff buff;
        ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>();
        MSSBamTableBuff[] buffList = readDerivedByEAccSecIdx(Authorization, EditAccessSecurityId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("TBL")) {
                filteredList.add((MSSBamTableBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableBuff[0]));
    }

    public MSSBamTableBuff[] readBuffByEAccFreqIdx(MSSBamAuthorization Authorization, Short EditAccessFrequencyId) {
        final String S_ProcName = "MSSBamRamTable.readBuffByEAccFreqIdx() ";
        MSSBamTableBuff buff;
        ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>();
        MSSBamTableBuff[] buffList = readDerivedByEAccFreqIdx(Authorization, EditAccessFrequencyId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("TBL")) {
                filteredList.add((MSSBamTableBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableBuff[0]));
    }

    public void updateTable(MSSBamAuthorization Authorization, MSSBamTableBuff Buff) {
        MSSBamAnyObjPKey pkey = schema.getFactoryAnyObj().newPKey();
        pkey.setRequiredId(Buff.getRequiredId());
        MSSBamTableBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateTable",
                    "Existing record not found", "Table", pkey);
        }
        MSSBamTableBySchemaIdxKey existingKeySchemaIdx = schema.getFactoryTable().newSchemaIdxKey();
        existingKeySchemaIdx.setRequiredSchemaId(existing.getRequiredSchemaId());

        MSSBamTableBySchemaIdxKey newKeySchemaIdx = schema.getFactoryTable().newSchemaIdxKey();
        newKeySchemaIdx.setRequiredSchemaId(Buff.getRequiredSchemaId());

        MSSBamTableBySchemaCdIdxKey existingKeySchemaCdIdx = schema.getFactoryTable().newSchemaCdIdxKey();
        existingKeySchemaCdIdx.setRequiredSchemaId(existing.getRequiredSchemaId());
        existingKeySchemaCdIdx.setRequiredTableClassCode(existing.getRequiredTableClassCode());

        MSSBamTableBySchemaCdIdxKey newKeySchemaCdIdx = schema.getFactoryTable().newSchemaCdIdxKey();
        newKeySchemaCdIdx.setRequiredSchemaId(Buff.getRequiredSchemaId());
        newKeySchemaCdIdx.setRequiredTableClassCode(Buff.getRequiredTableClassCode());

        MSSBamTableByPrimaryIndexIdxKey existingKeyPrimaryIndexIdx = schema.getFactoryTable()
                .newPrimaryIndexIdxKey();
        existingKeyPrimaryIndexIdx.setOptionalPrimaryIndexId(existing.getOptionalPrimaryIndexId());

        MSSBamTableByPrimaryIndexIdxKey newKeyPrimaryIndexIdx = schema.getFactoryTable().newPrimaryIndexIdxKey();
        newKeyPrimaryIndexIdx.setOptionalPrimaryIndexId(Buff.getOptionalPrimaryIndexId());

        MSSBamTableByLookupIndexIdxKey existingKeyLookupIndexIdx = schema.getFactoryTable().newLookupIndexIdxKey();
        existingKeyLookupIndexIdx.setOptionalLookupIndexId(existing.getOptionalLookupIndexId());

        MSSBamTableByLookupIndexIdxKey newKeyLookupIndexIdx = schema.getFactoryTable().newLookupIndexIdxKey();
        newKeyLookupIndexIdx.setOptionalLookupIndexId(Buff.getOptionalLookupIndexId());

        MSSBamTableByAltIndexIdxKey existingKeyAltIndexIdx = schema.getFactoryTable().newAltIndexIdxKey();
        existingKeyAltIndexIdx.setOptionalAltIndexId(existing.getOptionalAltIndexId());

        MSSBamTableByAltIndexIdxKey newKeyAltIndexIdx = schema.getFactoryTable().newAltIndexIdxKey();
        newKeyAltIndexIdx.setOptionalAltIndexId(Buff.getOptionalAltIndexId());

        MSSBamTableByQualTableIdxKey existingKeyQualTableIdx = schema.getFactoryTable().newQualTableIdxKey();
        existingKeyQualTableIdx.setOptionalQualifyingTableId(existing.getOptionalQualifyingTableId());

        MSSBamTableByQualTableIdxKey newKeyQualTableIdx = schema.getFactoryTable().newQualTableIdxKey();
        newKeyQualTableIdx.setOptionalQualifyingTableId(Buff.getOptionalQualifyingTableId());

        MSSBamTableByLoadBehaveIdxKey existingKeyLoadBehaveIdx = schema.getFactoryTable().newLoadBehaveIdxKey();
        existingKeyLoadBehaveIdx.setRequiredLoaderBehaviourId(existing.getRequiredLoaderBehaviourId());

        MSSBamTableByLoadBehaveIdxKey newKeyLoadBehaveIdx = schema.getFactoryTable().newLoadBehaveIdxKey();
        newKeyLoadBehaveIdx.setRequiredLoaderBehaviourId(Buff.getRequiredLoaderBehaviourId());

        MSSBamTableByDataScopeIdxKey existingKeyDataScopeIdx = schema.getFactoryTable().newDataScopeIdxKey();
        existingKeyDataScopeIdx.setOptionalDataScopeId(existing.getOptionalDataScopeId());

        MSSBamTableByDataScopeIdxKey newKeyDataScopeIdx = schema.getFactoryTable().newDataScopeIdxKey();
        newKeyDataScopeIdx.setOptionalDataScopeId(Buff.getOptionalDataScopeId());

        MSSBamTableBySecScopeIdxKey existingKeySecScopeIdx = schema.getFactoryTable().newSecScopeIdxKey();
        existingKeySecScopeIdx.setRequiredSecurityScopeId(existing.getRequiredSecurityScopeId());

        MSSBamTableBySecScopeIdxKey newKeySecScopeIdx = schema.getFactoryTable().newSecScopeIdxKey();
        newKeySecScopeIdx.setRequiredSecurityScopeId(Buff.getRequiredSecurityScopeId());

        MSSBamTableByVAccSecIdxKey existingKeyVAccSecIdx = schema.getFactoryTable().newVAccSecIdxKey();
        existingKeyVAccSecIdx.setOptionalViewAccessSecurityId(existing.getOptionalViewAccessSecurityId());

        MSSBamTableByVAccSecIdxKey newKeyVAccSecIdx = schema.getFactoryTable().newVAccSecIdxKey();
        newKeyVAccSecIdx.setOptionalViewAccessSecurityId(Buff.getOptionalViewAccessSecurityId());

        MSSBamTableByVAccFreqIdxKey existingKeyVAccFreqIdx = schema.getFactoryTable().newVAccFreqIdxKey();
        existingKeyVAccFreqIdx.setOptionalViewAccessFrequencyId(existing.getOptionalViewAccessFrequencyId());

        MSSBamTableByVAccFreqIdxKey newKeyVAccFreqIdx = schema.getFactoryTable().newVAccFreqIdxKey();
        newKeyVAccFreqIdx.setOptionalViewAccessFrequencyId(Buff.getOptionalViewAccessFrequencyId());

        MSSBamTableByEAccSecIdxKey existingKeyEAccSecIdx = schema.getFactoryTable().newEAccSecIdxKey();
        existingKeyEAccSecIdx.setOptionalEditAccessSecurityId(existing.getOptionalEditAccessSecurityId());

        MSSBamTableByEAccSecIdxKey newKeyEAccSecIdx = schema.getFactoryTable().newEAccSecIdxKey();
        newKeyEAccSecIdx.setOptionalEditAccessSecurityId(Buff.getOptionalEditAccessSecurityId());

        MSSBamTableByEAccFreqIdxKey existingKeyEAccFreqIdx = schema.getFactoryTable().newEAccFreqIdxKey();
        existingKeyEAccFreqIdx.setOptionalEditAccessFrequencyId(existing.getOptionalEditAccessFrequencyId());

        MSSBamTableByEAccFreqIdxKey newKeyEAccFreqIdx = schema.getFactoryTable().newEAccFreqIdxKey();
        newKeyEAccFreqIdx.setOptionalEditAccessFrequencyId(Buff.getOptionalEditAccessFrequencyId());

        // Check unique indexes

        if (!existingKeySchemaCdIdx.equals(newKeySchemaCdIdx)) {
            if (dictBySchemaCdIdx.containsKey(newKeySchemaCdIdx)) {
                throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "updateTable",
                        "TableSchemaCodeIdx", newKeySchemaCdIdx);
            }
        }

        // Validate foreign keys

        {
            boolean allNull = true;

            if (allNull) {
                if (null == schema.getTableScope().readDerivedByIdIdx(Authorization, Buff.getRequiredId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "updateTable", "Superclass", "SuperClass", "Scope", null);
                }
            }
        }

        {
            boolean allNull = true;

            if (allNull) {
                if (null == schema.getTableSchemaDef().readDerivedByIdIdx(Authorization,
                        Buff.getRequiredSchemaId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "updateTable", "Container", "Schema", "SchemaDef", null);
                }
            }
        }

        {
            boolean allNull = true;

            if (allNull) {
                if (null == schema.getTableLoaderBehaviour().readDerivedByIdIdx(Authorization,
                        Buff.getRequiredLoaderBehaviourId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "updateTable", "Lookup", "LoaderBehaviour", "LoaderBehaviour", null);
                }
            }
        }

        {
            boolean allNull = true;

            if (allNull) {
                if (null == schema.getTableSecurityScope().readDerivedByIdIdx(Authorization,
                        Buff.getRequiredSecurityScopeId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "updateTable", "Lookup", "SecurityScope", "SecurityScope", null);
                }
            }
        }

        // Update is valid

        SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdict;

        dictByPKey.remove(pkey);
        dictByPKey.put(pkey, Buff);

        subdict = dictBySchemaIdx.get(existingKeySchemaIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictBySchemaIdx.containsKey(newKeySchemaIdx)) {
            subdict = dictBySchemaIdx.get(newKeySchemaIdx);
        } else {
            subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>();
            dictBySchemaIdx.put(newKeySchemaIdx, subdict);
        }
        subdict.put(pkey, Buff);

        dictBySchemaCdIdx.remove(existingKeySchemaCdIdx);
        dictBySchemaCdIdx.put(newKeySchemaCdIdx, Buff);

        subdict = dictByPrimaryIndexIdx.get(existingKeyPrimaryIndexIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByPrimaryIndexIdx.containsKey(newKeyPrimaryIndexIdx)) {
            subdict = dictByPrimaryIndexIdx.get(newKeyPrimaryIndexIdx);
        } else {
            subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>();
            dictByPrimaryIndexIdx.put(newKeyPrimaryIndexIdx, subdict);
        }
        subdict.put(pkey, Buff);

        subdict = dictByLookupIndexIdx.get(existingKeyLookupIndexIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByLookupIndexIdx.containsKey(newKeyLookupIndexIdx)) {
            subdict = dictByLookupIndexIdx.get(newKeyLookupIndexIdx);
        } else {
            subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>();
            dictByLookupIndexIdx.put(newKeyLookupIndexIdx, subdict);
        }
        subdict.put(pkey, Buff);

        subdict = dictByAltIndexIdx.get(existingKeyAltIndexIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByAltIndexIdx.containsKey(newKeyAltIndexIdx)) {
            subdict = dictByAltIndexIdx.get(newKeyAltIndexIdx);
        } else {
            subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>();
            dictByAltIndexIdx.put(newKeyAltIndexIdx, subdict);
        }
        subdict.put(pkey, Buff);

        subdict = dictByQualTableIdx.get(existingKeyQualTableIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByQualTableIdx.containsKey(newKeyQualTableIdx)) {
            subdict = dictByQualTableIdx.get(newKeyQualTableIdx);
        } else {
            subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>();
            dictByQualTableIdx.put(newKeyQualTableIdx, subdict);
        }
        subdict.put(pkey, Buff);

        subdict = dictByLoadBehaveIdx.get(existingKeyLoadBehaveIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByLoadBehaveIdx.containsKey(newKeyLoadBehaveIdx)) {
            subdict = dictByLoadBehaveIdx.get(newKeyLoadBehaveIdx);
        } else {
            subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>();
            dictByLoadBehaveIdx.put(newKeyLoadBehaveIdx, subdict);
        }
        subdict.put(pkey, Buff);

        subdict = dictByDataScopeIdx.get(existingKeyDataScopeIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByDataScopeIdx.containsKey(newKeyDataScopeIdx)) {
            subdict = dictByDataScopeIdx.get(newKeyDataScopeIdx);
        } else {
            subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>();
            dictByDataScopeIdx.put(newKeyDataScopeIdx, subdict);
        }
        subdict.put(pkey, Buff);

        subdict = dictBySecScopeIdx.get(existingKeySecScopeIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictBySecScopeIdx.containsKey(newKeySecScopeIdx)) {
            subdict = dictBySecScopeIdx.get(newKeySecScopeIdx);
        } else {
            subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>();
            dictBySecScopeIdx.put(newKeySecScopeIdx, subdict);
        }
        subdict.put(pkey, Buff);

        subdict = dictByVAccSecIdx.get(existingKeyVAccSecIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByVAccSecIdx.containsKey(newKeyVAccSecIdx)) {
            subdict = dictByVAccSecIdx.get(newKeyVAccSecIdx);
        } else {
            subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>();
            dictByVAccSecIdx.put(newKeyVAccSecIdx, subdict);
        }
        subdict.put(pkey, Buff);

        subdict = dictByVAccFreqIdx.get(existingKeyVAccFreqIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByVAccFreqIdx.containsKey(newKeyVAccFreqIdx)) {
            subdict = dictByVAccFreqIdx.get(newKeyVAccFreqIdx);
        } else {
            subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>();
            dictByVAccFreqIdx.put(newKeyVAccFreqIdx, subdict);
        }
        subdict.put(pkey, Buff);

        subdict = dictByEAccSecIdx.get(existingKeyEAccSecIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByEAccSecIdx.containsKey(newKeyEAccSecIdx)) {
            subdict = dictByEAccSecIdx.get(newKeyEAccSecIdx);
        } else {
            subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>();
            dictByEAccSecIdx.put(newKeyEAccSecIdx, subdict);
        }
        subdict.put(pkey, Buff);

        subdict = dictByEAccFreqIdx.get(existingKeyEAccFreqIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByEAccFreqIdx.containsKey(newKeyEAccFreqIdx)) {
            subdict = dictByEAccFreqIdx.get(newKeyEAccFreqIdx);
        } else {
            subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>();
            dictByEAccFreqIdx.put(newKeyEAccFreqIdx, subdict);
        }
        subdict.put(pkey, Buff);

    }

    public void deleteTable(MSSBamAuthorization Authorization, MSSBamTableBuff Buff) {
        final String S_ProcName = "MSSBamRamTableTable.deleteTable() ";
        MSSBamAnyObjPKey pkey = schema.getFactoryAnyObj().newPKey();

        pkey.setRequiredId(schema.nextAnyObjIdGen());
        MSSBamTableBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "deleteTable",
                    "Existing record not found", "Table", pkey);
        }
        if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
            throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteTable", pkey);
        }
        MSSBamTableBySchemaIdxKey keySchemaIdx = schema.getFactoryTable().newSchemaIdxKey();
        keySchemaIdx.setRequiredSchemaId(existing.getRequiredSchemaId());

        MSSBamTableBySchemaCdIdxKey keySchemaCdIdx = schema.getFactoryTable().newSchemaCdIdxKey();
        keySchemaCdIdx.setRequiredSchemaId(existing.getRequiredSchemaId());
        keySchemaCdIdx.setRequiredTableClassCode(existing.getRequiredTableClassCode());

        MSSBamTableByPrimaryIndexIdxKey keyPrimaryIndexIdx = schema.getFactoryTable().newPrimaryIndexIdxKey();
        keyPrimaryIndexIdx.setOptionalPrimaryIndexId(existing.getOptionalPrimaryIndexId());

        MSSBamTableByLookupIndexIdxKey keyLookupIndexIdx = schema.getFactoryTable().newLookupIndexIdxKey();
        keyLookupIndexIdx.setOptionalLookupIndexId(existing.getOptionalLookupIndexId());

        MSSBamTableByAltIndexIdxKey keyAltIndexIdx = schema.getFactoryTable().newAltIndexIdxKey();
        keyAltIndexIdx.setOptionalAltIndexId(existing.getOptionalAltIndexId());

        MSSBamTableByQualTableIdxKey keyQualTableIdx = schema.getFactoryTable().newQualTableIdxKey();
        keyQualTableIdx.setOptionalQualifyingTableId(existing.getOptionalQualifyingTableId());

        MSSBamTableByLoadBehaveIdxKey keyLoadBehaveIdx = schema.getFactoryTable().newLoadBehaveIdxKey();
        keyLoadBehaveIdx.setRequiredLoaderBehaviourId(existing.getRequiredLoaderBehaviourId());

        MSSBamTableByDataScopeIdxKey keyDataScopeIdx = schema.getFactoryTable().newDataScopeIdxKey();
        keyDataScopeIdx.setOptionalDataScopeId(existing.getOptionalDataScopeId());

        MSSBamTableBySecScopeIdxKey keySecScopeIdx = schema.getFactoryTable().newSecScopeIdxKey();
        keySecScopeIdx.setRequiredSecurityScopeId(existing.getRequiredSecurityScopeId());

        MSSBamTableByVAccSecIdxKey keyVAccSecIdx = schema.getFactoryTable().newVAccSecIdxKey();
        keyVAccSecIdx.setOptionalViewAccessSecurityId(existing.getOptionalViewAccessSecurityId());

        MSSBamTableByVAccFreqIdxKey keyVAccFreqIdx = schema.getFactoryTable().newVAccFreqIdxKey();
        keyVAccFreqIdx.setOptionalViewAccessFrequencyId(existing.getOptionalViewAccessFrequencyId());

        MSSBamTableByEAccSecIdxKey keyEAccSecIdx = schema.getFactoryTable().newEAccSecIdxKey();
        keyEAccSecIdx.setOptionalEditAccessSecurityId(existing.getOptionalEditAccessSecurityId());

        MSSBamTableByEAccFreqIdxKey keyEAccFreqIdx = schema.getFactoryTable().newEAccFreqIdxKey();
        keyEAccFreqIdx.setOptionalEditAccessFrequencyId(existing.getOptionalEditAccessFrequencyId());

        // Validate reverse foreign keys

        if (schema.getTableIndex().readDerivedByTableIdx(Authorization, existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "Table", "Index", pkey);
        }

        if (schema.getTableRelation().readDerivedByFromTblIdx(Authorization, existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "FromTable", "Relation", pkey);
        }

        if (schema.getTableRelation().readDerivedByToTblIdx(Authorization, existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Lookup", "ToTable", "Relation", pkey);
        }

        if (schema.getTableChain().readDerivedByTableIdx(Authorization, existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "Table", "Chain", pkey);
        }

        if (schema.getTableDelTopDep().readDerivedByContTblIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "ContTable", "DelTopDep", pkey);
        }

        if (schema.getTableClearTopDep().readDerivedByContTblIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "ContTable", "ClearTopDep", pkey);
        }

        if (schema.getTableTableBlob().readDerivedByContainerIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "CTable", "TableBlob", pkey);
        }

        if (schema.getTableTableBool().readDerivedByContainerIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "CTable", "TableBool", pkey);
        }

        if (schema.getTableTableDate().readDerivedByContainerIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "CTable", "TableDate", pkey);
        }

        if (schema.getTableTableDouble().readDerivedByContainerIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "Table", "TableDouble", pkey);
        }

        if (schema.getTableTableNumber().readDerivedByContainerIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "Table", "TableNumber", pkey);
        }

        if (schema.getTableTableFloat().readDerivedByContainerIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "CTable", "TableFloat", pkey);
        }

        if (schema.getTableTableInt16().readDerivedByContainerIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "CTable", "TableInt16", pkey);
        }

        if (schema.getTableTableEnum().readDerivedByContainerIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "CTable", "TableEnum", pkey);
        }

        if (schema.getTableTableId16Gen().readDerivedByContainerIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "CTable", "TableId16Gen", pkey);
        }

        if (schema.getTableTableUInt16().readDerivedByContainerIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "CTable", "TableUInt16", pkey);
        }

        if (schema.getTableTableInt32().readDerivedByContainerIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "CTable", "TableInt32", pkey);
        }

        if (schema.getTableTableId32Gen().readDerivedByContainerIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "CTable", "TableId32Gen", pkey);
        }

        if (schema.getTableTableUInt32().readDerivedByContainerIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "CTable", "TableUInt32", pkey);
        }

        if (schema.getTableTableInt64().readDerivedByContainerIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "CTable", "TableInt64", pkey);
        }

        if (schema.getTableTableId64Gen().readDerivedByContainerIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "CTable", "TableId64Gen", pkey);
        }

        if (schema.getTableTableUInt64().readDerivedByContainerIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "CTable", "TableUInt64", pkey);
        }

        if (schema.getTableTableNmToken().readDerivedByContainerIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "CTable", "TableNmToken", pkey);
        }

        if (schema.getTableTableNmTokens().readDerivedByContainerIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "CTable", "TableNmTokens", pkey);
        }

        if (schema.getTableTableString().readDerivedByContainerIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "CTable", "TableString", pkey);
        }

        if (schema.getTableTableTZDate().readDerivedByContainerIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "CTable", "TableTZDate", pkey);
        }

        if (schema.getTableTableTZTime().readDerivedByContainerIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "CTable", "TableTZTime", pkey);
        }

        if (schema.getTableTableTZTimestamp().readDerivedByContainerIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "CTable", "TableTZTimestamp", pkey);
        }

        if (schema.getTableTableText().readDerivedByContainerIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "CTable", "TableText", pkey);
        }

        if (schema.getTableTableTime().readDerivedByContainerIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "CTable", "TableTime", pkey);
        }

        if (schema.getTableTableTimestamp().readDerivedByContainerIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "CTable", "TableTimestamp", pkey);
        }

        if (schema.getTableTableToken().readDerivedByContainerIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "CTable", "TableToken", pkey);
        }

        if (schema.getTableTableUuid().readDerivedByContainerIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "CTable", "TableUuid", pkey);
        }

        if (schema.getTableTableUuidGen().readDerivedByContainerIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "CTable", "TableUuidGen", pkey);
        }

        if (schema.getTableTableCol().readDerivedByCTableIdx(Authorization, existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable",
                    "Container", "CTable", "TableCol", pkey);
        }

        // Delete is valid

        SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdict;

        dictByPKey.remove(pkey);

        subdict = dictBySchemaIdx.get(keySchemaIdx);
        subdict.remove(pkey);

        dictBySchemaCdIdx.remove(keySchemaCdIdx);

        subdict = dictByPrimaryIndexIdx.get(keyPrimaryIndexIdx);
        subdict.remove(pkey);

        subdict = dictByLookupIndexIdx.get(keyLookupIndexIdx);
        subdict.remove(pkey);

        subdict = dictByAltIndexIdx.get(keyAltIndexIdx);
        subdict.remove(pkey);

        subdict = dictByQualTableIdx.get(keyQualTableIdx);
        subdict.remove(pkey);

        subdict = dictByLoadBehaveIdx.get(keyLoadBehaveIdx);
        subdict.remove(pkey);

        subdict = dictByDataScopeIdx.get(keyDataScopeIdx);
        subdict.remove(pkey);

        subdict = dictBySecScopeIdx.get(keySecScopeIdx);
        subdict.remove(pkey);

        subdict = dictByVAccSecIdx.get(keyVAccSecIdx);
        subdict.remove(pkey);

        subdict = dictByVAccFreqIdx.get(keyVAccFreqIdx);
        subdict.remove(pkey);

        subdict = dictByEAccSecIdx.get(keyEAccSecIdx);
        subdict.remove(pkey);

        subdict = dictByEAccFreqIdx.get(keyEAccFreqIdx);
        subdict.remove(pkey);

    }

    public MSSBamCursor openTableCursorAll(MSSBamAuthorization Authorization) {
        MSSBamCursor cursor = new MSSBamRamTableCursor(Authorization, schema, dictByPKey.values());
        return (cursor);
    }

    public MSSBamCursor openTableCursorBySchemaIdx(MSSBamAuthorization Authorization, long SchemaId) {
        MSSBamCursor cursor;
        MSSBamTableBySchemaIdxKey key = schema.getFactoryTable().newSchemaIdxKey();
        key.setRequiredSchemaId(SchemaId);

        if (dictBySchemaIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictSchemaIdx = dictBySchemaIdx.get(key);
            cursor = new MSSBamRamTableCursor(Authorization, schema, subdictSchemaIdx.values());
        } else {
            cursor = new MSSBamRamTableCursor(Authorization, schema, new ArrayList<MSSBamTableBuff>());
        }
        return (cursor);
    }

    public MSSBamCursor openTableCursorByPrimaryIndexIdx(MSSBamAuthorization Authorization, Long PrimaryIndexId) {
        MSSBamCursor cursor;
        MSSBamTableByPrimaryIndexIdxKey key = schema.getFactoryTable().newPrimaryIndexIdxKey();
        key.setOptionalPrimaryIndexId(PrimaryIndexId);

        if (dictByPrimaryIndexIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictPrimaryIndexIdx = dictByPrimaryIndexIdx.get(key);
            cursor = new MSSBamRamTableCursor(Authorization, schema, subdictPrimaryIndexIdx.values());
        } else {
            cursor = new MSSBamRamTableCursor(Authorization, schema, new ArrayList<MSSBamTableBuff>());
        }
        return (cursor);
    }

    public MSSBamCursor openTableCursorByLookupIndexIdx(MSSBamAuthorization Authorization, Long LookupIndexId) {
        MSSBamCursor cursor;
        MSSBamTableByLookupIndexIdxKey key = schema.getFactoryTable().newLookupIndexIdxKey();
        key.setOptionalLookupIndexId(LookupIndexId);

        if (dictByLookupIndexIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictLookupIndexIdx = dictByLookupIndexIdx.get(key);
            cursor = new MSSBamRamTableCursor(Authorization, schema, subdictLookupIndexIdx.values());
        } else {
            cursor = new MSSBamRamTableCursor(Authorization, schema, new ArrayList<MSSBamTableBuff>());
        }
        return (cursor);
    }

    public MSSBamCursor openTableCursorByAltIndexIdx(MSSBamAuthorization Authorization, Long AltIndexId) {
        MSSBamCursor cursor;
        MSSBamTableByAltIndexIdxKey key = schema.getFactoryTable().newAltIndexIdxKey();
        key.setOptionalAltIndexId(AltIndexId);

        if (dictByAltIndexIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictAltIndexIdx = dictByAltIndexIdx.get(key);
            cursor = new MSSBamRamTableCursor(Authorization, schema, subdictAltIndexIdx.values());
        } else {
            cursor = new MSSBamRamTableCursor(Authorization, schema, new ArrayList<MSSBamTableBuff>());
        }
        return (cursor);
    }

    public MSSBamCursor openTableCursorByQualTableIdx(MSSBamAuthorization Authorization, Long QualifyingTableId) {
        MSSBamCursor cursor;
        MSSBamTableByQualTableIdxKey key = schema.getFactoryTable().newQualTableIdxKey();
        key.setOptionalQualifyingTableId(QualifyingTableId);

        if (dictByQualTableIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictQualTableIdx = dictByQualTableIdx.get(key);
            cursor = new MSSBamRamTableCursor(Authorization, schema, subdictQualTableIdx.values());
        } else {
            cursor = new MSSBamRamTableCursor(Authorization, schema, new ArrayList<MSSBamTableBuff>());
        }
        return (cursor);
    }

    public MSSBamCursor openTableCursorByLoadBehaveIdx(MSSBamAuthorization Authorization, short LoaderBehaviourId) {
        MSSBamCursor cursor;
        MSSBamTableByLoadBehaveIdxKey key = schema.getFactoryTable().newLoadBehaveIdxKey();
        key.setRequiredLoaderBehaviourId(LoaderBehaviourId);

        if (dictByLoadBehaveIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictLoadBehaveIdx = dictByLoadBehaveIdx.get(key);
            cursor = new MSSBamRamTableCursor(Authorization, schema, subdictLoadBehaveIdx.values());
        } else {
            cursor = new MSSBamRamTableCursor(Authorization, schema, new ArrayList<MSSBamTableBuff>());
        }
        return (cursor);
    }

    public MSSBamCursor openTableCursorByDataScopeIdx(MSSBamAuthorization Authorization, Short DataScopeId) {
        MSSBamCursor cursor;
        MSSBamTableByDataScopeIdxKey key = schema.getFactoryTable().newDataScopeIdxKey();
        key.setOptionalDataScopeId(DataScopeId);

        if (dictByDataScopeIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictDataScopeIdx = dictByDataScopeIdx.get(key);
            cursor = new MSSBamRamTableCursor(Authorization, schema, subdictDataScopeIdx.values());
        } else {
            cursor = new MSSBamRamTableCursor(Authorization, schema, new ArrayList<MSSBamTableBuff>());
        }
        return (cursor);
    }

    public MSSBamCursor openTableCursorBySecScopeIdx(MSSBamAuthorization Authorization, short SecurityScopeId) {
        MSSBamCursor cursor;
        MSSBamTableBySecScopeIdxKey key = schema.getFactoryTable().newSecScopeIdxKey();
        key.setRequiredSecurityScopeId(SecurityScopeId);

        if (dictBySecScopeIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictSecScopeIdx = dictBySecScopeIdx.get(key);
            cursor = new MSSBamRamTableCursor(Authorization, schema, subdictSecScopeIdx.values());
        } else {
            cursor = new MSSBamRamTableCursor(Authorization, schema, new ArrayList<MSSBamTableBuff>());
        }
        return (cursor);
    }

    public MSSBamCursor openTableCursorByVAccSecIdx(MSSBamAuthorization Authorization, Short ViewAccessSecurityId) {
        MSSBamCursor cursor;
        MSSBamTableByVAccSecIdxKey key = schema.getFactoryTable().newVAccSecIdxKey();
        key.setOptionalViewAccessSecurityId(ViewAccessSecurityId);

        if (dictByVAccSecIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictVAccSecIdx = dictByVAccSecIdx.get(key);
            cursor = new MSSBamRamTableCursor(Authorization, schema, subdictVAccSecIdx.values());
        } else {
            cursor = new MSSBamRamTableCursor(Authorization, schema, new ArrayList<MSSBamTableBuff>());
        }
        return (cursor);
    }

    public MSSBamCursor openTableCursorByVAccFreqIdx(MSSBamAuthorization Authorization,
            Short ViewAccessFrequencyId) {
        MSSBamCursor cursor;
        MSSBamTableByVAccFreqIdxKey key = schema.getFactoryTable().newVAccFreqIdxKey();
        key.setOptionalViewAccessFrequencyId(ViewAccessFrequencyId);

        if (dictByVAccFreqIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictVAccFreqIdx = dictByVAccFreqIdx.get(key);
            cursor = new MSSBamRamTableCursor(Authorization, schema, subdictVAccFreqIdx.values());
        } else {
            cursor = new MSSBamRamTableCursor(Authorization, schema, new ArrayList<MSSBamTableBuff>());
        }
        return (cursor);
    }

    public MSSBamCursor openTableCursorByEAccSecIdx(MSSBamAuthorization Authorization, Short EditAccessSecurityId) {
        MSSBamCursor cursor;
        MSSBamTableByEAccSecIdxKey key = schema.getFactoryTable().newEAccSecIdxKey();
        key.setOptionalEditAccessSecurityId(EditAccessSecurityId);

        if (dictByEAccSecIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictEAccSecIdx = dictByEAccSecIdx.get(key);
            cursor = new MSSBamRamTableCursor(Authorization, schema, subdictEAccSecIdx.values());
        } else {
            cursor = new MSSBamRamTableCursor(Authorization, schema, new ArrayList<MSSBamTableBuff>());
        }
        return (cursor);
    }

    public MSSBamCursor openTableCursorByEAccFreqIdx(MSSBamAuthorization Authorization,
            Short EditAccessFrequencyId) {
        MSSBamCursor cursor;
        MSSBamTableByEAccFreqIdxKey key = schema.getFactoryTable().newEAccFreqIdxKey();
        key.setOptionalEditAccessFrequencyId(EditAccessFrequencyId);

        if (dictByEAccFreqIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictEAccFreqIdx = dictByEAccFreqIdx.get(key);
            cursor = new MSSBamRamTableCursor(Authorization, schema, subdictEAccFreqIdx.values());
        } else {
            cursor = new MSSBamRamTableCursor(Authorization, schema, new ArrayList<MSSBamTableBuff>());
        }
        return (cursor);
    }

    public void closeTableCursor(MSSBamCursor Cursor) {
        // Cursor.DataReader.Close();
    }

    public MSSBamTableBuff nextTableCursor(MSSBamCursor Cursor) {
        MSSBamRamTableCursor cursor = (MSSBamRamTableCursor) Cursor;
        MSSBamTableBuff rec = cursor.getCursor().next();
        cursor.setRowIdx(cursor.getRowIdx() + 1);
        return (rec);
    }

    public MSSBamTableBuff prevTableCursor(MSSBamCursor Cursor) {
        int targetRowIdx = (Cursor.getRowIdx() > 1) ? Cursor.getRowIdx() - 1 : 1;
        MSSBamTableBuff rec = null;
        if (Cursor.getRowIdx() >= targetRowIdx) {
            Cursor.reset();
        }
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextTableCursor(Cursor);
        }
        return (rec);
    }

    public MSSBamTableBuff firstTableCursor(MSSBamCursor Cursor) {
        int targetRowIdx = 1;
        MSSBamTableBuff rec = null;
        Cursor.reset();
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextTableCursor(Cursor);
        }
        return (rec);
    }

    public MSSBamTableBuff lastTableCursor(MSSBamCursor Cursor) {
        throw CFLib.getDefaultExceptionFactory().newNotImplementedYetException(getClass(), "lastTableCursor");
    }

    public MSSBamTableBuff nthTableCursor(MSSBamCursor Cursor, int Idx) {
        int targetRowIdx = Idx;
        MSSBamTableBuff rec = null;
        if (Cursor.getRowIdx() >= targetRowIdx) {
            Cursor.reset();
        }
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextTableCursor(Cursor);
        }
        return (rec);
    }
}