Package com.softwaremining.sql
Interface ISQLWrapper
- All Superinterfaces:
IPersistence,ISMBean
- All Known Implementing Classes:
AbstractIndexedFile,AbstractORContainer,CachedSQLWrapper,CAIdealWrapper,CicsIndexedFile,CicsPersistence,Db400,Db400Container,Db400Sequential,DBMSWrapper,IDS2Wrapper,ImsDbSegment,LinkedSQLWrapper,QueueRecord,SQLWrapper,TSQueueStorageImpl
Interface for Object-Relational classes talking to a database
-
Field Summary
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_CLOSE_FILE_FILE_NOT_OPEN, 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_OPEN_FILE_FILE_NOT_FOUND, STATUS_REWRITE_WITHOUT_READ, STATUS_SM_FAIL_UNKOWN_REASON, STATUS_SM_NOT_ASSIGNED, STATUS_SUCCESS, UNCERTAIN_OF_RETURN_VALUE -
Method Summary
Modifier and TypeMethodDescriptionvoidassignAccessMode(int accessMode) voidassignAdditionalSQLConditions(String condition) This method allows inserting additional conditions - e.g.voidassignAdditionalSQLConditions(StringBuilder condition) This method allows inserting additional conditions - e.g.voidThis method allows appending to current SQL Conditions without overwriting previous conditionsvoidassignAdditionalSQLOrderBy(String newValue) This method allows inserting additional Ordering clauses It is useful in hierarchical tables will define additional SQLConditions - e.g.voidassignCachedSeekValues(List objects) voidassignChangeGEConditonToLIKE(boolean newValue) The system can replace GE searches to LIKE statements.voidassignChangeGTEQ2EQForLIKECondition(boolean useEQForExactLenghtMatch) Only applies when OR_CHANGE_GE_CONDITION_TO_LIKE__DEFAULT=true
E.g.voidassignConnection(Connection connection) voidassignDbDecorator(ACMDbDecorator dbDecorator) voidassignDelegateDAO(ISQLWrapper delegateDAO) voidassignExpandGTEQSearches(boolean expandGTEQSearches) (default is true) Example: Lets say there are 3 key fields involved in a search with condition GTEQ
If flag is set to true (default) - then the following SQL condition will be generated
(A > ? or (A = ? and B > ?) or (A = ? and B = ? and C >= ?))
With flag is set to FALSE - the following will be generated
(A >= ?) and (B >= ?) and (C >= ?)voidassignFetchDirectionIsForward(Boolean direction) voidassignFileOpened(boolean fileOpened) voidassignGDGCondition(String gdgCondition) Additional SQL statement to be read from gdg.properties file.voidassignGDGProperty(String gdgProperty) Additional SQL statement to be read from gdg.properties file.voidassignGenerate_OrderBy_ForReadStatements(boolean enabled) READ() statement on DB tables with MANY rows, issues an ORDER BY on the SELECT which may have a big performance impact.voidassignIgnoreOriginalKeys(boolean newValue) for internal usevoidassignIncludeRedefinedFieldsInCRUD(boolean includeRedefinedFieldsInCRUD) voidassignKeyIsUnique(boolean keyUnique) voidUsed only used by CicsPersistent Subclasses.voidassignLastSeekCondition(int lastSeekCondition) voidassignLastSeekConditionLookedForEquality(boolean newValue) voidassignLowerLimitForExpandGTEQSearches(int range) (default is -1 - disabled) Only works when assignExpandGTEQSearches(true);
Example: Lets say there are 3 key fields involved in a search with condition GTEQ
In default settings, the following SQL condition will be generatedvoidassignOpenMode(int openMode) voidassignRecordKey(ISMObject recordKey) Used only used by CicsPersistent Subclasses.voidassignRecordKey(ISMObject[] recordKeys) Used only used by CicsPersistent Subclasses.voidassignResultSet(ResultSet resultSet) voidassignResultSetFetchSize(int newFetchSize) voidassignRowFacade(RowFacade rowFacade) voidassignSequentialKeyGeneration(boolean sequentialKeyGeneration) voidassignSQLConditions(String condition)
Ignore the inbuilt KEY (defined by assignRecordKey(...)) - and use this condition instead
Please note program will be responsible for passing additional parameters.voidassignSQLTableName(String newName) Change the underlying SQL table-name FROM persistent-ClassesvoidassignStatus(ISMObject status) voidassignStatusValue(int newValue) voidassignSuppressSeek(boolean newValue) for internal use only - For VSAM SEEK / READ / ...voidassignTableName(String newName) Change the underlying SQL table-name FROM PROGRAMSvoidassignThrowInvalidKeyException(boolean newValue) for internal use only - For VSAM SEEK / READ / ...voidassignTopRowSelectStrategyCount(int count) (Default = -1) When set to 0 or 1 , the Object-Relation SQL Generator will produce:voidassignTopRowSelectStrategyRange(int startRowNumber, int count) Similar to assignTopRowSelectStrategyCount - but aslso defines starting pointsvoidassignTreatAsSQLWrapper(boolean treatAsSQLWrapper) Used only used by CicsPersistent Subclasses.voidassignUpperLimitForExpandGTEQSearches(int range) (default is -1 - disabled) Only works when assignExpandGTEQSearches(true);
Example: Lets say there are 3 key fields involved in a search with condition GTEQ
In default settings, the following SQL condition will be generatedvoidintclose()intdelete()intinsert()booleaninternal use only.booleanThe system can replace GE searches to LIKE statements.booleanFor internal Use only.booleanbooleanbooleanbooleanbooleanisKept()booleanbooleanbooleanused in AS400 / DB400 to increase speed of searchesbooleanfor internal use only - For VSAM SEEK / READ / ...booleanbooleanintnext()intprev()intread()voidreduceGEorEQ(boolean newValue) used in AS400 / DB400 to increase speed of searchesintintintassignSQLCondition can also have conditions such as "NAME = ?".booleanfor internal usefor internal use onlybooleanintintUsed only used by CicsPersistent Subclasses.intFor internal use onlyintbooleanfor internal use only - For VSAM SEEK / READ / ...intFor internal use only (Default = -1) When set to 0 or 1 , the Object-Relation SQL Generator will produce:intfor internal use onlyintseekRecord(ISMObject[] keys, int conditionType) intseekRecord(ISMObject key, int conditionType) voidsetLock(boolean newValue) voidunlock()intupdate()booleanintvalidateConditionType(ISMObject key, int conditionType) For internal use only reverts to defaults for CONDITION_TYPE_NO_CONDITION and CONDITION_TYPE_NOT_ASSIGNEDMethods inherited from interface com.softwaremining.wrappers.ISMBean
assignExemptFromMemRelease, assignSessionId, assignValue, initialize, isExemptFromMemRelease, isResourceAlreadyReleased, releaseResources, resetStructure, retrieveActualLength, retrieveAsString, retrieveField, retrieveField, retrieveTopLevelField, retrieveValue, stringValue
-
Method Details
-
retrieveStatusValue
int retrieveStatusValue() -
retrieveNativeKeys
ISMObject[] retrieveNativeKeys() -
retrieveAdditionalSQLOrderBy
StringBuilder retrieveAdditionalSQLOrderBy() -
retrieveAdditionalSQLCondition
StringBuilder retrieveAdditionalSQLCondition() -
assignResultSet
-
retrieveResultSet
ResultSet retrieveResultSet() -
assignStatusValue
void assignStatusValue(int newValue) -
isKept
boolean isKept() -
setLock
void setLock(boolean newValue) -
unlock
void unlock() -
useOidTableForKeyGeneration
boolean useOidTableForKeyGeneration() -
assignDelegateDAO
-
retrieveDelegateDAO
ISQLWrapper retrieveDelegateDAO() -
retrieveConnection
Connection retrieveConnection() -
assignConnection
-
assignFetchDirectionIsForward
-
isFetchDirectionForward
boolean isFetchDirectionForward() -
isFetchDirectionBackward
boolean isFetchDirectionBackward() -
retrieveIncludeRedefinedFieldsInCRUD
boolean retrieveIncludeRedefinedFieldsInCRUD() -
assignIncludeRedefinedFieldsInCRUD
void assignIncludeRedefinedFieldsInCRUD(boolean includeRedefinedFieldsInCRUD) -
validateConditionType
For internal use only reverts to defaults for CONDITION_TYPE_NO_CONDITION and CONDITION_TYPE_NOT_ASSIGNED- Parameters:
conditionType-- Returns:
-
retrieveImplicitDatabaseKey
ISMObject retrieveImplicitDatabaseKey()for internal use only- Returns:
-
assignRecordKey
Used only used by CicsPersistent Subclasses. -
assignRecordKey
Used only used by CicsPersistent Subclasses. -
assignTreatAsSQLWrapper
void assignTreatAsSQLWrapper(boolean treatAsSQLWrapper) Used only used by CicsPersistent Subclasses. allows CicsPersistent (ILE or other subclasses of this) to be treated as SQLWrapper (Object-relational VSAM Files) by batch programs. -
close
- Throws:
IOCriticalException
-
assignAdditionalSQLOrderBy
This method allows inserting additional Ordering clauses It is useful in hierarchical tables will define additional SQLConditions - e.g. (INDX_FLD_TABLE_1 ASCENDING)- Parameters:
condition-
-
assignSQLConditions
Ignore the inbuilt KEY (defined by assignRecordKey(...)) - and use this condition instead
Please note program will be responsible for passing additional parameters.
e.g. assignSQLConditions("NAME = 'SMITH");
(or when assignSQLConditions("NAME = ?") - the program should also use the "addSearchParameter" method to provide values- Parameters:
condition-
-
assignAdditionalSQLConditions
This method allows inserting additional conditions - e.g. assignAdditionalSQLConditions( "(COLUMN_2 = 12)"); It is useful in hierarchical tables will define additional SQLConditions - e.g. (INDX_FLD_TABLE_1 = 12), as well as GDG support- Parameters:
condition-
-
assignAdditionalSQLConditions
This method allows inserting additional conditions - e.g. assignAdditionalSQLConditions( "(COLUMN_2 = 12)"); It is useful in hierarchical tables will define additional SQLConditions - e.g. (INDX_FLD_TABLE_1 = 12), as well as GDG support- Parameters:
condition-
-
assignAdditionalSQLForeignKeyCondition
This method allows appending to current SQL Conditions without overwriting previous conditions- Parameters:
condition-
-
clearAdditionalSQLCondition
void clearAdditionalSQLCondition() -
retrieveAdditionalSearchParameters
assignSQLCondition can also have conditions such as "NAME = ?". In that case the program should also use the "addSearchParameter" method to provide values- Returns:
-
assignTableName
Change the underlying SQL table-name FROM PROGRAMS- Parameters:
newName-
-
assignSQLTableName
Change the underlying SQL table-name FROM persistent-Classes- Parameters:
newName-
-
retrieveTableName
String retrieveTableName() -
assignResultSetFetchSize
void assignResultSetFetchSize(int newFetchSize) -
next
int next() -
prev
int prev() -
read
int read() -
insert
int insert() -
delete
int delete() -
update
int update() -
retrieveAscentDescendOrder
-
retrieveResultSetFetchSize
int retrieveResultSetFetchSize() -
isFileOpened
boolean isFileOpened() -
assignFileOpened
void assignFileOpened(boolean fileOpened) -
assignStatus
-
retrieveAccessMode
int retrieveAccessMode() -
assignAccessMode
void assignAccessMode(int accessMode) -
retrieveSessionId
Long retrieveSessionId()Description copied from interface:ISMBeanFor internal use only- Specified by:
retrieveSessionIdin interfaceISMBean
-
retrieveRowFacade
RowFacade retrieveRowFacade() -
assignRowFacade
-
retrieveDbDecorator
ACMDbDecorator retrieveDbDecorator() -
assignDbDecorator
-
retrieveLastSeekCondition
int retrieveLastSeekCondition() -
assignLastSeekCondition
void assignLastSeekCondition(int lastSeekCondition) -
assignOpenMode
void assignOpenMode(int openMode) -
retrieveOpenMode
int retrieveOpenMode() -
isSequentialKeyGeneration
boolean isSequentialKeyGeneration() -
assignSequentialKeyGeneration
void assignSequentialKeyGeneration(boolean sequentialKeyGeneration) -
assignLastSeekConditionLookedForEquality
void assignLastSeekConditionLookedForEquality(boolean newValue) -
isLastSeekConditionLookedForEquality
boolean isLastSeekConditionLookedForEquality() -
isKeyUnique
boolean isKeyUnique() -
assignKeyIsUnique
void assignKeyIsUnique(boolean keyUnique) -
isSuppressNextReadCurrent
boolean isSuppressNextReadCurrent() -
retrieveFileName
String retrieveFileName() -
reduceGEorEQ
void reduceGEorEQ(boolean newValue) used in AS400 / DB400 to increase speed of searches -
isReduceGEorEQ
boolean isReduceGEorEQ()used in AS400 / DB400 to increase speed of searches -
isAllowedToExpandGTEQSearches
boolean isAllowedToExpandGTEQSearches()internal use only. Example: Lets say there are 3 key fields involved in a search with condition GTEQ
If flag is set to true (default) - then the following SQL condition will be generated
(A > ? or (A = ? and B > ?) or (A = ? and B = ? and C >= ?))
With flag is set to FALSE - the following will be generated
(A >= ?) and (B >= ?) and (C >= ?)- Parameters:
newValue-
-
assignExpandGTEQSearches
void assignExpandGTEQSearches(boolean expandGTEQSearches) (default is true) Example: Lets say there are 3 key fields involved in a search with condition GTEQ
If flag is set to true (default) - then the following SQL condition will be generated
(A > ? or (A = ? and B > ?) or (A = ? and B = ? and C >= ?))
With flag is set to FALSE - the following will be generated
(A >= ?) and (B >= ?) and (C >= ?)- Parameters:
newValue-
-
assignLowerLimitForExpandGTEQSearches
void assignLowerLimitForExpandGTEQSearches(int range) (default is -1 - disabled) Only works when assignExpandGTEQSearches(true);
Example: Lets say there are 3 key fields involved in a search with condition GTEQ
In default settings, the following SQL condition will be generatedSELECT ... FROM ... WHERE (A > ?) or (A = ? and B > ?) or (A = ? and B = ? and C >= ?))
using the statement assignLowerLimitForExpandGTEQSearches( 3 ) - the key conditions below position 3 are ignored, and only the following is generated.SELECT ... FROM ... WHERE (A = ? and B = ? and C >= ?))
and the following proceeding conditions are ignored <> (A > ?)
or (A = ? and B > ?) -
retreiveLowerLimitForExpandGTEQSearches
int retreiveLowerLimitForExpandGTEQSearches() -
assignUpperLimitForExpandGTEQSearches
void assignUpperLimitForExpandGTEQSearches(int range) (default is -1 - disabled) Only works when assignExpandGTEQSearches(true);
Example: Lets say there are 3 key fields involved in a search with condition GTEQ
In default settings, the following SQL condition will be generatedSELECT ... FROM ... WHERE (A > ?) or (A = ? and B > ?) or (A = ? and B = ? and C >= ?))
but if assignUpperLimitForExpandGTEQSearches( 1 ) - only conditions up to 1st Key will be generated
ie The following will be generatedSELECT ... FROM ... WHERE (A > ?)
and the following conditions will NOT be generated (A = ? and B > ?) or (A = ? and B = ? and C >= ?)) -
retreiveUpperLimitForExpandGTEQSearches
int retreiveUpperLimitForExpandGTEQSearches() -
isChangeGEConditonToLIKE
boolean isChangeGEConditonToLIKE()The system can replace GE searches to LIKE statements. this can potentially have a huge performance improvement.
E.g. Consider generating SELECT ... from TABLE WHERE KEY_1 >= ? AND KEY_2 >= ?.
If each key is 5 chars, and the supplied values are "A " and "B " - the above translates to:SELECT ... from TABLE WHERE KEY_1 >= 'A ' AND KEY_2 >= 'B '.
Converting it to LIKE will becomeSELECT ... from TABLE WHERE KEY_1 LIKE 'A%' AND KEY_2 LIKE 'B%'
This makes a significant performance improvements. -
assignChangeGEConditonToLIKE
void assignChangeGEConditonToLIKE(boolean newValue) The system can replace GE searches to LIKE statements. this can potentially have a huge performance improvement.
E.g. Consider generating SELECT ... from TABLE WHERE KEY_1 >= ? AND KEY_2 >= ?.
If each key is 5 chars, and the supplied values are "A " and "B " - the above translates to:SELECT ... from TABLE WHERE KEY_1 >= 'A ' AND KEY_2 >= 'B '.
Converting it to LIKE will becomeSELECT ... from TABLE WHERE KEY_1 LIKE 'A%' AND KEY_2 LIKE 'B%'
This makes a significant performance improvements. -
isChangeGTEQ2EQForLIKECondition
boolean isChangeGTEQ2EQForLIKECondition()For internal Use only.
Only applies when OR_CHANGE_GE_CONDITION_TO_LIKE__DEFAULT=true
E.g. Consider generating SELECT ... from TABLE WHERE KEY_1 >= ? AND KEY_2 >= ?.
If each key is 5 chars, and the supplied values are "ABCDE" and "B " - the above translates to:SELECT ... from TABLE WHERE KEY_1 >= 'ABCDE' AND KEY_2 >= 'B '.
Converting it to LIKE will becomeSELECT ... from TABLE WHERE KEY_1 >= 'ABCDE' AND KEY_2 LIKE 'B%'
When this flag is set, if the char-count of a field is equal to that of the supplied value, then the generated SQL will becomeSELECT ... from TABLE WHERE KEY_1 = 'ABCDE' AND KEY_2 LIKE 'B%'
This can make a significant improvement to performance . -
assignChangeGTEQ2EQForLIKECondition
void assignChangeGTEQ2EQForLIKECondition(boolean useEQForExactLenghtMatch) Only applies when OR_CHANGE_GE_CONDITION_TO_LIKE__DEFAULT=true
E.g. Consider generating SELECT ... from TABLE WHERE KEY_1 >= ? AND KEY_2 >= ?.
If each key is 5 chars, and the supplied values are "ABCDE" and "B " - the above translates to:SELECT ... from TABLE WHERE KEY_1 >= 'ABCDE' AND KEY_2 >= 'B '.
Converting it to LIKE will becomeSELECT ... from TABLE WHERE KEY_1 >= 'ABCDE' AND KEY_2 LIKE 'B%'
When this flag is set, if the char-count of a field is equal to that of the supplied value, then the generated SQL will becomeSELECT ... from TABLE WHERE KEY_1 = 'ABCDE' AND KEY_2 LIKE 'B%'
This can make a significant improvement to performance . -
assignTopRowSelectStrategyCount
void assignTopRowSelectStrategyCount(int count) (Default = -1) When set to 0 or 1 , the Object-Relation SQL Generator will produce:SELECT � FROM table WHERE condition-1
When set to greater than 1 - (for Oracle) it will produce:SELECT ... FROM ( SELECT � FROM table WHERE condition-1 ) WHERE ROWNUM <OR_SELECT_TOP_ROW__DEFAULT;
-
retrieveTopRowSelectStrategyCount
int retrieveTopRowSelectStrategyCount()For internal use only (Default = -1) When set to 0 or 1 , the Object-Relation SQL Generator will produce:SELECT ... FROM table WHERE condition-1
When set to greater than 1 - (for Oracle) it will produce:SELECT ... FROM ( SELECT ... FROM table WHERE condition-1 ) WHERE ROWNUM <OR_SELECT_TOP_ROW__DEFAULT;
-
retrieveTopRowSelectStrategyStartingRow
int retrieveTopRowSelectStrategyStartingRow()for internal use only -
assignTopRowSelectStrategyRange
void assignTopRowSelectStrategyRange(int startRowNumber, int count) Similar to assignTopRowSelectStrategyCount - but aslso defines starting points- Parameters:
startRowNumber-count-
-
assignGenerate_OrderBy_ForReadStatements
void assignGenerate_OrderBy_ForReadStatements(boolean enabled) READ() statement on DB tables with MANY rows, issues an ORDER BY on the SELECT which may have a big performance impact. If the data was populated sequentially, then the ORDER BY may not be strictly required, and may be removed. -
retrieveGenerate_OrderBy_ForReadStatements
boolean retrieveGenerate_OrderBy_ForReadStatements()for internal use- Parameters:
newValue-
-
assignIgnoreOriginalKeys
void assignIgnoreOriginalKeys(boolean newValue) for internal use- Parameters:
newValue-
-
isIgnoreOriginalKeys
boolean isIgnoreOriginalKeys() -
assignCachedSeekValues
-
retrieveCachedSeekValues
List retrieveCachedSeekValues() -
seekRecord
-
seekRecord
- Throws:
IOStatusException
-
assignGDGProperty
Additional SQL statement to be read from gdg.properties file. E.g. assignGDGProperty("GDG1"); If gdg.properties file contains: GDG1=AND GDG_YEAR=2012 Then the above search condition will be appended to any SQL statements issued reading this class -
assignGDGCondition
Additional SQL statement to be read from gdg.properties file. E.g. assignGDGCondition("GDG_YEAR = 2013"); Then the above search condition will be appended to any SQL statements issued reading this class. -
assignKeyValue
Used only used by CicsPersistent Subclasses. After each read or next, it will update the value of the Key with the new values from database- Parameters:
value-
-
retrieveRecordKeyValue
String retrieveRecordKeyValue()Used only used by CicsPersistent Subclasses.- Parameters:
value-
-
retrieveRecordKey
ISMObject retrieveRecordKey() -
retrieveThrowInvalidKeyException
boolean retrieveThrowInvalidKeyException()for internal use only - For VSAM SEEK / READ / ... VSAM apps need to throw InvalidKeyException (even if they use CICS delegates), but CICS applications need to throw KeyNotFoundException ,- Returns:
-
assignThrowInvalidKeyException
void assignThrowInvalidKeyException(boolean newValue) for internal use only - For VSAM SEEK / READ / ... VSAM apps need to throw InvalidKeyException (even if they use CICS delegates), but CICS applications need to throw KeyNotFoundException , -
isSeekSuppressed
boolean isSeekSuppressed()for internal use only - For VSAM SEEK / READ / ... VSAM apps need to throw InvalidKeyException (even if they use CICS delegates), but CICS applications need to throw KeyNotFoundException ,- Returns:
-
assignSuppressSeek
void assignSuppressSeek(boolean newValue) for internal use only - For VSAM SEEK / READ / ... VSAM apps need to throw InvalidKeyException (even if they use CICS delegates), but CICS applications need to throw KeyNotFoundException ,
-