Package com.softwaremining.sql
Class CachedSQLWrapper
java.lang.Object
com.softwaremining.wrappers.CBLBean
com.softwaremining.wrappers.AbstractBasePersistence
com.softwaremining.sql.AbstractIndexedFile
com.softwaremining.sql.SQLWrapper
com.softwaremining.sql.CachedSQLWrapper
- All Implemented Interfaces:
IPersistence
,ISQLWrapper
,AbstractDataObject
,ICBLBeanNGroup
,ICBLContainer
,IFieldContainer
,ISMBean
,ISMDataType
Cached table is for Reference Data only.
Reference data are NOT written back to the database, only read.
They are read from database - (when open() method is called) - and loaded into memory.
This is useful for load large amounts of static data which either needs to be accessed by different programs (only 1 copy will be cached), or if the application can be started from an Application-Server, and hence the data will stay in memory whilst AppServer is alive.
To use - find a persistent class which inherits from SQLWrapper or AbstractORContainer , and change its superclass to CachedSQLWrapper.
NOTE: the amount of data cached can be limited by applying additional sql statement via,
Example
This is useful for load large amounts of static data which either needs to be accessed by different programs (only 1 copy will be cached), or if the application can be started from an Application-Server, and hence the data will stay in memory whilst AppServer is alive.
To use - find a persistent class which inherits from SQLWrapper or AbstractORContainer , and change its superclass to CachedSQLWrapper.
NOTE: the amount of data cached can be limited by applying additional sql statement via,
record.assignSQLConditions("EVENT_DATE > 2000" ); record.open(IPersistence.OPEN_MODE_INPUT);Also, the design only works for searching for KEY EQUALS OR GT TO VALUE
Example
MyCachedSQLWrapper instance = new MyCachedSQLWrapper(); instance.open(IPersistence.OPEN_MODE_INPUT); // generates SQL, reads and caches the values instance.setIDKey( 123 ); // assuming the SQL Table has field ID defined as a key instance.seekRecord( cachedAcct.getObjectIDKey()); // search the cache for the ID (value 123) - automatically populate fields in instance instance.close(); // release cache memory
-
Field Summary
Fields inherited from class com.softwaremining.sql.SQLWrapper
connection, nativeKeys, openMode, postFixTableNameToImplicitDatabaseKey, resultSet, sequentialKeyGeneration, suppressNextReadCurrent
Fields inherited from class com.softwaremining.sql.AbstractIndexedFile
delegateDAO
Fields inherited from class com.softwaremining.wrappers.AbstractBasePersistence
fileName, ownerClassName, status
Fields inherited from class com.softwaremining.wrappers.CBLBean
EBCDIC_JIT_PD_SUPPORT_FOR_SEQ_FILES, INDEX_FOR_NON_ARRAY_VERSION_OF_FIELD, INDEX_ZERO, tmp_lengthofAssignedValue, totalRuntime_allocate, totalRuntime_calcFieldOffsets, totalRuntime_getMemoryPosition, totalRuntime_setFieldFormatted
Fields inherited from interface com.softwaremining.sql.IPersistence
ACCESS_MODE_DYNAMIC, ACCESS_MODE_RANDOM, ACCESS_MODE_SEQUENTIAL, ASCENDING_RECORD_KEY, CONDITION_TYPE_EQUALS, CONDITION_TYPE_GREATER, CONDITION_TYPE_GREATER_OR_EQUALS, CONDITION_TYPE_IGNORE, CONDITION_TYPE_IGNORE_FOR_SQL_LIKE, CONDITION_TYPE_LESS, CONDITION_TYPE_LESS_OR_EQUALS, CONDITION_TYPE_LIKE, CONDITION_TYPE_NO_CONDITION, CONDITION_TYPE_NOT_ASSIGNED, DESCENDING_RECORD_KEY, OPEN_MODE_EXTEND, OPEN_MODE_I_O, OPEN_MODE_INPUT, OPEN_MODE_NOT_OPENED, OPEN_MODE_OUTPUT, STATUS_AT_END, STATUS_DUP_KEY, STATUS_FAILED_CLOSING, STATUS_INCORRECT_READ_OF_UNOPENED_FILE, STATUS_INCORRECT_RECORDSIZE_REWRITE, STATUS_INSERT_ERR_INAPPROPRIATE_FILE, STATUS_INSERT_ERR_INVALID_KEY, STATUS_LOCK, STATUS_NOT_FOUND, STATUS_REWRITE_WITHOUT_READ, STATUS_SM_FAIL_UNKOWN_REASON, STATUS_SM_NOT_ASSIGNED, STATUS_SUCCESS, UNCERTAIN_OF_RETURN_VALUE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
_seekRecord
(ISMObject[] keys, int conditionType) for internal use onlyint
clear()
clear the result-sets and statements ...int
close()
Close the fileint
delete()
NOT SUPPORTED - this is a read-only data cacheint
NOT SUPPORTED - this is a read-only data cachevoid
first()
Goto first record (as organized by key's)int
NOT SUPPORTED - this is a read-only data cachevoid
last()
Goto last record (as organized by key's)int
read next recordint
open
(int openMode) Opens and reads all the information into memory (if not there already)int
read previous recordint
read()
Read record which matches record-keyint
update()
NOT SUPPORTED - this is a read-only data cacheMethods inherited from class com.softwaremining.sql.SQLWrapper
_clear, _close, _commit, _deleteAllRecord, _deleteRecord, _insertRecord, _nextRecord, _open, _prevRecord, _readRecord, _readWithLock, _rollback, _unlock, _updateRecord, addRecordKey, addSearchParameter, addSearchParameter, assignAdditionalKeyPosition, assignAdditionalSQLConditions, assignAdditionalSQLConditions, assignAdditionalSQLOrderBy, assignAlternateKey, assignCachedSeekValues, assignChangeGEConditonToLIKE, assignChangeGTEQ2EQForLIKECondition, assignConnection, assignDbDecorator, assignExpandGTEQSearches, assignFetchDirectionIsForward, assignFetchSize, assignFileOpened, assignGDGCondition, assignGDGProperty, assignGenerate_OrderBy_ForReadStatements, assignIgnoreOriginalKeys, assignKeyIsUnique, assignKeyValue, assignKeyValue, assignLastSeekCondition, assignLastSeekConditionLookedForEquality, assignLowerLimitForExpandGTEQSearches, assignOpenMode, assignRecordKey, assignRecordKey, assignRecordKeysAllDescending, assignRelativeKey, assignResultSet, assignResultSetFetchSize, assignRowFacade, assignSequentialKeyGeneration, assignSQLConditions, assignSQLTableName, assignSuppressSeek, assignTableName, assignThrowInvalidKeyException, assignTopRowSelectStrategyCount, assignTopRowSelectStrategyRange, assignTreatAsSQLWrapper, assignUpperLimitForExpandGTEQSearches, clearSearchParameter, createAndretrieveSearchParameterInstance, isAllowedToExpandGTEQSearches, isChangeGEConditonToLIKE, isChangeGTEQ2EQForLIKECondition, isFetchDirectionBackward, isFetchDirectionForward, isFileOpened, isIgnoreOriginalKeys, isKept, isKeyUnique, isLastSeekConditionLookedForEquality, isReduceGEorEQ, isSeekSuppressed, isSequentialKeyGeneration, isSuppressNextReadCurrent, readCurrent, reduceGEorEQ, releaseResources, releaseResources, resetRowFacade, restoreResultSet, retreiveLowerLimitForExpandGTEQSearches, retreiveUpperLimitForExpandGTEQSearches, retrieveAdditionalSearchParameters, retrieveAdditionalSQLCondition, retrieveAdditionalSQLOrderBy, retrieveAscentDescendOrder, retrieveCachedSeekValues, retrieveConnection, retrieveDbDecorator, retrieveForeignKeys, retrieveGenerate_OrderBy_ForReadStatements, retrieveImplicitDatabaseKey, retrieveLastSeekCondition, retrieveNativeKeys, retrieveOpenMode, retrieveRecordKey, retrieveRecordKeyValue, retrieveResultSet, retrieveResultSetFetchSize, retrieveRowFacade, retrieveTableName, retrieveThrowInvalidKeyException, retrieveTopRowSelectStrategyCount, retrieveTopRowSelectStrategyStartingRow, setLock, setRelativeKey, trimCachedSeekValues, useOidTableForKeyGeneration, validateConditionType
Methods inherited from class com.softwaremining.sql.AbstractIndexedFile
_assignKeyValue, assignAccessMode, assignDelegateDAO, assignStatus, commit, deleteAllRecord, insert, next, prev, readRecord, readWithLock, resetCicsDelegate, retrieveDelegateDAO, rollback, seek, seek, seekRecord, seekRecord, seekRecord, unlock, updateRecord
Methods inherited from class com.softwaremining.wrappers.AbstractBasePersistence
assignFileName, assignLock, assignStatus, assignStatusAsPrimitive, assignStatusValue, assignStatusValue, readRow, retrieveAccessMode, retrieveFileName, retrieveFileName, retrieveFirstLevelEntry, retrieveSessionId, retrieveStatusField, retrieveStatusValue
Methods inherited from class com.softwaremining.wrappers.CBLBean
addCorrespondingValue, addCorrespondingValue, allocate, assignAddressTo, assignAddressTo, assignBean, assignBytesEncoded, assignCachedInitializationValue, assignCorrespondingValue, assignCorrespondingValue, assignDefaultValue, assignDependingField, assignEbcdicBytes, assignEbcdicJIT_PdSupportForSequentialFiles, assignEncodedValue, assignExemptFromMemRelease, assignExternal, assignHighValues, assignInternalVars, assignLowValues, assignRawEbcdicBytes, assignRecordSize, assignRedefines, assignRedefines, assignSessionId, assignStringFormatted, assignSubstring, assignSubstring, assignToAddressOf, assignToAddressOf, assignToAddressOf, assignToAddressOf, assignToAllFields, assignValue, assignValue, assignValue, assignValue, assignValue, assignValue, assignValue, calculateStorageSize, containsPointers, equals, equals, equals, equals, equalsRightTrimmed, fieldsCount, fill, fill, fill, fill, fill, getValue, hasPackedDecimalFields, initDefaultValues, initialize, initialize, isExemptFromMemRelease, isFilled, isFilled, isFilled, isFilled, isGreaterThan, isGreaterThan, isGreaterThan, isHighValues, isInvolvedInDependency, isInvolvedInExternalDependency, isLessOrEqualTo, isLessOrEqualTo, isLessOrEqualTo, isLessOrEqualTo, isLessOrEqualTo, isLessThan, isLessThan, isLessThan, isLessThan, isLessThan, isLowValues, isRedefinedByAnotherClass, isResourceAlreadyReleased, lengthOf, printFieldPosition, printFieldValues, printOrderedFieldPosition, PrintOrderedFieldPositionsAndValue, resetCachedValues, resetCompressedFieldList, resetStructure, resize, retrieveActualLength, retrieveAsInt, retrieveAsString, retrieveCachedInitializationValue, retrieveCompressedFields, retrieveDependedFieldsList, retrieveEbcdicBytes, retrieveEbcdicValue, retrieveEncodedValue, retrieveField, retrieveField, retrieveFieldAtMemoryPosition, retrieveFieldFormatted, retrieveFields, retrieveIsTargetOfPointers, retrievePrimitiveFields, retrieveRawEbcdicBytes, retrieveSQLObject, retrieveStorageCellSize, retrieveStorageChars, retrieveSubstring, retrieveSubstring, retrieveTopLevelField, retrieveValue, retrieveValue, setValue, stringValue, subtractCorrespondingValue, subtractCorrespondingValue, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.softwaremining.wrappers.ISMBean
assignExemptFromMemRelease, assignSessionId, assignValue, initialize, isExemptFromMemRelease, isResourceAlreadyReleased, resetStructure, retrieveActualLength, retrieveAsString, retrieveField, retrieveField, retrieveTopLevelField, retrieveValue, stringValue
Methods inherited from interface com.softwaremining.sql.ISQLWrapper
assignStatusValue, retrieveAccessMode, retrieveFileName, retrieveSessionId, retrieveStatusValue
-
Constructor Details
-
CachedSQLWrapper
public CachedSQLWrapper()constructor -
CachedSQLWrapper
Constructor -- Parameters:
owner
-
-
-
Method Details
-
open
Opens and reads all the information into memory (if not there already)- Overrides:
open
in classAbstractIndexedFile
- Throws:
IOCriticalException
-
close
Description copied from class:AbstractBasePersistence
Close the file- Specified by:
close
in interfaceISQLWrapper
- Overrides:
close
in classAbstractIndexedFile
- Returns:
- when successful it returns IPersistence.STATUS_SUCCESS
- Throws:
IOCriticalException
-
_seekRecord
for internal use only- Overrides:
_seekRecord
in classSQLWrapper
- Throws:
IOStatusException
-
nextRecord
read next record- Overrides:
nextRecord
in classAbstractIndexedFile
- Returns:
- IPersistence.STATUS_SUCCESS if records are found, Otherwise returns other values from IPersistence;
- Throws:
IOStatusException
-
prevRecord
read previous record- Overrides:
prevRecord
in classAbstractIndexedFile
- Returns:
- IPersistence.STATUS_SUCCESS if records are found, Otherwise returns other values from IPersistence;
- Throws:
IOStatusException
-
first
Goto first record (as organized by key's)- Throws:
IOStatusException
-
last
Goto last record (as organized by key's)- Throws:
IOStatusException
-
read
Read record which matches record-key- Specified by:
read
in interfaceISQLWrapper
- Overrides:
read
in classAbstractIndexedFile
- Returns:
- IPersistence.STATUS_SUCCESS if records are found, Otherwise returns other values from IPersistence;
- Throws:
IOStatusException
-
update
NOT SUPPORTED - this is a read-only data cache- Specified by:
update
in interfaceISQLWrapper
- Overrides:
update
in classAbstractIndexedFile
- Throws:
IOStatusException
-
insertRecord
NOT SUPPORTED - this is a read-only data cache- Overrides:
insertRecord
in classAbstractIndexedFile
- Returns:
- when successful it returns IPersistence.STATUS_SUCCESS
- Throws:
IOStatusException
-
delete
NOT SUPPORTED - this is a read-only data cache- Specified by:
delete
in interfaceISQLWrapper
- Overrides:
delete
in classAbstractIndexedFile
- Throws:
IOStatusException
-
deleteRecord
NOT SUPPORTED - this is a read-only data cache- Overrides:
deleteRecord
in classAbstractIndexedFile
- Returns:
- when successful it returns IPersistence.STATUS_SUCCESS
- Throws:
IOStatusException
-
clear
Description copied from class:AbstractIndexedFile
clear the result-sets and statements ...- Overrides:
clear
in classAbstractIndexedFile
- Returns:
- when successful it returns IPersistence.STATUS_SUCCESS
- Throws:
IOStatusException
-