org.jpox.store.rdbms.adapter
Class DB2Adapter

java.lang.Object
  extended by org.jpox.store.mapped.AbstractDatastoreAdapter
      extended by org.jpox.store.rdbms.adapter.DatabaseAdapter
          extended by org.jpox.store.rdbms.adapter.DB2Adapter
All Implemented Interfaces:
org.jpox.store.mapped.DatastoreAdapter, org.jpox.store.mapped.expression.ExpressionConversionAdapter, org.jpox.store.mapped.expression.ExpressionLogicSetAdapter, org.jpox.store.mapped.expression.ExpressionMethodAdapter, org.jpox.store.mapped.expression.ExpressionOperatorAdapter, org.jpox.store.mapped.expression.ExpressionPatternAdapter, org.jpox.store.mapped.expression.ExpressionSupportedFeaturesAdapter, RDBMSAdapter
Direct Known Subclasses:
DB2AS400Adapter

public class DB2Adapter
extends DatabaseAdapter

Provides methods for adapting SQL language elements to the DB2 database.

Version:
$Revision: 1.35 $
See Also:
DatabaseAdapter

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jpox.store.rdbms.adapter.DatabaseAdapter
DatabaseAdapter.JDBCTypeInfo
 
Field Summary
static java.lang.String DB2_RESERVED_WORDS
          A string containing the list of DB2 keywords This list is normally obtained dynamically from the driver using DatabaseMetaData.getSQLKeywords() Based on database DB2 version 7
 
Fields inherited from class org.jpox.store.rdbms.adapter.DatabaseAdapter
catalogSeparator, driverMajorVersion, driverMinorVersion, driverName, driverVersion, LOCALISER, maxColumnNameLength, maxConstraintNameLength, maxIndexNameLength, maxTableNameLength, storesLowerCaseIdentifiers, storesLowerCaseQuotedIdentifiers, storesMixedCaseIdentifiers, storesMixedCaseQuotedIdentifiers, storesMixedCaseQuotedSensitiveIdentifiers, storesMixedCaseSensitiveIdentifiers, storesUpperCaseIdentifiers, storesUpperCaseQuotedIdentifiers, supportsCatalogsInTableDefinitions, supportsSchemasInTableDefinitions, supportsStatementBatching, typesByTypeNumber
 
Fields inherited from class org.jpox.store.mapped.AbstractDatastoreAdapter
datastoreMajorVersion, datastoreMinorVersion, datastoreProductName, datastoreProductVersion, datastoreRevisionVersion, identifierQuoteString, LOCALISER_BASE, mappingManager, reservedKeywords
 
Constructor Summary
DB2Adapter(java.sql.DatabaseMetaData metadata)
          Constructs a DB2 adapter based on the given JDBC metadata.
 
Method Summary
 void closeConnection(java.sql.Connection conn)
          Method to close a Connection to the datastore.
 org.jpox.store.mapped.expression.ScalarExpression concatOperator(org.jpox.store.mapped.expression.ScalarExpression operand1, org.jpox.store.mapped.expression.ScalarExpression operand2)
           If only one operand expression is of type String, then string conversion is performed on the other operand to produce a string at run time.
 org.jpox.store.mapped.expression.BooleanExpression endsWithMethod(org.jpox.store.mapped.expression.ScalarExpression leftOperand, org.jpox.store.mapped.expression.ScalarExpression rightOperand)
          Returns whether this string ends with the specified string.
 java.lang.String getAutoIncrementKeyword()
          Accessor for the auto-increment keyword for generating DDLs (CREATE TABLEs...).
 java.lang.String getAutoIncrementStmt(Table table, java.lang.String columnName)
          Accessor for the auto-increment sql statement for this datastore.
 java.lang.String getContinuationString()
          Continuation string to use where the SQL statement goes over more than 1 line.
 java.lang.String getDropTableStatement(org.jpox.store.mapped.DatastoreContainerObject table)
          Returns the appropriate SQL to drop the given table.
 int getMaxConstraintNameLength()
          Accessor for the maximum constraint name length permitted on this datastore.
 int getMaxIndexNameLength()
          Accessor for the maximum index name length permitted on this datastore.
 java.lang.String getSchemaName(java.sql.Connection conn)
          Accessor for the Schema Name for this datastore.
 java.lang.String getSequenceCreateStmt(java.lang.String sequence_name, java.lang.String min, java.lang.String max, java.lang.String start, java.lang.String increment, java.lang.String cache_size)
          Accessor for the sequence statement to create the sequence.
 java.lang.String getSequenceNextStmt(java.lang.String sequence_name)
          Accessor for the statement for getting the next id from the sequence for this datastore.
 int getUnlimitedLengthPrecisionValue(TypeInfo typeInfo)
          Returns the precision value to be used when creating string columns of "unlimited" length.
 java.lang.String getVendorID()
           
 org.jpox.store.mapped.expression.NumericExpression indexOfMethod(org.jpox.store.mapped.expression.ScalarExpression source, org.jpox.store.mapped.expression.ScalarExpression str, org.jpox.store.mapped.expression.NumericExpression from)
          Returns the appropriate SQL expression for the JDOQL String.indexOf() method.
 org.jpox.store.mapped.expression.NumericExpression lengthMethod(org.jpox.store.mapped.expression.StringExpression str)
          Returns the appropriate SQL expression for the JDOQL String.length() method.
 org.jpox.store.mapped.expression.NumericExpression modOperator(org.jpox.store.mapped.expression.ScalarExpression operand1, org.jpox.store.mapped.expression.ScalarExpression operand2)
          Method to generate a modulus expression.
 ColumnInfo newColumnInfo(java.sql.ResultSet rs)
          A factory for ColumnInfo objects.
 org.jpox.store.mapped.expression.LogicSetExpression newTableExpression(org.jpox.store.mapped.expression.QueryExpression qs, org.jpox.store.mapped.DatastoreContainerObject table, org.jpox.store.mapped.DatastoreIdentifier rangeVar)
          Returns a new TableExpression object appropriate for this DBMS.
 TypeInfo newTypeInfo(java.sql.ResultSet rs)
          A factory for TypeInfo objects.
 org.jpox.store.mapped.expression.BooleanExpression startsWithMethod(org.jpox.store.mapped.expression.ScalarExpression source, org.jpox.store.mapped.expression.ScalarExpression str)
          Method to handle the starts with operation.
 org.jpox.store.mapped.expression.StringExpression substringMethod(org.jpox.store.mapped.expression.StringExpression str, org.jpox.store.mapped.expression.NumericExpression begin)
          Returns the appropriate SQL expression for the JDOQL String.substring(str,begin) method.
 org.jpox.store.mapped.expression.StringExpression substringMethod(org.jpox.store.mapped.expression.StringExpression str, org.jpox.store.mapped.expression.NumericExpression begin, org.jpox.store.mapped.expression.NumericExpression end)
          Returns the appropriate SQL expression for the JDOQL String.substring(str,begin,end) method.
 boolean supportsBooleanComparison()
          Whether we support Boolean comparisons.
 boolean supportsDeferredConstraints()
          Whether this datastore supports deferred constraints.
 boolean supportsForeignKeyDeleteAction(ForeignKey.FKAction action)
          Whether this datastore supports the specified foreign key delete action
 boolean supportsForeignKeyUpdateAction(ForeignKey.FKAction action)
          Whether this datastore supports the specified foreign key update action
 boolean supportsIdentityFields()
          Whether we support auto-increment fields.
 boolean supportsLockWithSelectForUpdate()
          Whether this datastore supports locking using SELECT ...
 boolean supportsNullsInCandidateKeys()
          Whether we support NULLs in candidate keys.
 boolean supportsNullsKeywordInColumnOptions()
          Whether the database support NULLs in the column options for table creation.
 boolean supportsSequences()
          Whether we support sequences.
 org.jpox.store.mapped.expression.StringExpression toStringExpression(org.jpox.store.mapped.expression.StringLiteral expr)
          A String conversion that converts a String literal to String expression.
 org.jpox.store.mapped.expression.StringExpression translateMethod(org.jpox.store.mapped.expression.ScalarExpression expr, org.jpox.store.mapped.expression.ScalarExpression toExpr, org.jpox.store.mapped.expression.ScalarExpression fromExpr)
          Method to translate all chars in this expression to the fromExpr which corresponds to toExpr.
 org.jpox.store.mapped.expression.StringExpression trimMethod(org.jpox.store.mapped.expression.StringExpression str, boolean leading, boolean trailing)
          Returns the appropriate SQL expression for the java query "trim" method.
 
Methods inherited from class org.jpox.store.rdbms.adapter.DatabaseAdapter
absMethod, acosMethod, addTypeInfo, asinMethod, atanMethod, cartersianProduct, ceilMethod, cosMethod, createIndexesBeforeForeignKeys, expMethod, floorMethod, getAddCandidateKeyStatement, getAddColumnStatement, getAddForeignKeyStatement, getAddPrimaryKeyStatement, getCatalogName, getCatalogSeparator, getCharColumnsPaddedWithSpaces, getCheckConstraintForValues, getColumns, getColumns, getConnection, getCreateIndexStatement, getCreateTableStatement, getCurrentDateMethod, getCurrentTimeMethod, getCurrentTimestampMethod, getDatastoreDateStatement, getDayMethod, getDriverMajorVersion, getDriverMinorVersion, getDropViewStatement, getEscapeCharacter, getEscapedPatternExpression, getEscapePatternExpression, getExistingIndexes, getHourMethod, getInsertStatementForNoColumns, getMaxColumnNameLength, getMaxForeignKeys, getMaxIndexes, getMaxTableNameLength, getMinuteMethod, getMonthMethod, getNewMappingManager, getNewUUIDFunction, getNonAnsiInnerJoinWhereClause, getNonAnsiLeftOuterJoinWhereClause, getNonAnsiRightOuterJoinWhereClause, getOperatorConcat, getPatternExpressionAnyCharacter, getPatternExpressionZeroMoreCharacters, getPlaceWithOptionAfterFromClause, getPlaceWithOptionWithinJoinClauses, getRangeByLimitSelectClause, getRangeByLimitWhereClause, getRangeByRowNumberColumn, getRequiredTransactionIsolationLevel, getSecondMethod, getSelectNewUUIDStmt, getSelectWithLockOption, getSupportsPersistOfUnassignedChar, getSurrogateForEmptyStrings, getTables, getTransactionIsolationForSchemaCreation, getTypeInfo, getYearMethod, includeOrderByColumnsInSelect, initialiseDatastore, isIdentityFieldDataType, isNullEqualsEmptyStrings, isSQLKeyword, isStoresLowerCaseIdentifiers, isStoresLowerCaseQuotedIdentifiers, isStoresMixedCaseIdentifiers, isStoresMixedCaseQuotedIdentifiers, isStoresUpperCaseIdentifiers, isStoresUpperCaseQuotedIdentifiers, isValidPrimaryKeyType, iteratorReservedWords, iteratorTypeInfo, loadDatastoreMapping, logConfiguration, logMethod, matchesMethod, newExportedKeyInfo, newForeignKeyInfo, newQueryStatement, newQueryStatement, parseKeywordList, requiresColumnDefaultsInitialising, setDefaultTypeInfoForJDBCType, sinMethod, sqrtMethod, supportsAlterTableDropConstraint, supportsAlterTableDropForeignKeyConstraint, supportsAnalysisMethods, supportsAnsiJoinSyntax, supportsAutoIncrementColumnTypeSpecification, supportsAutoIncrementKeysNullSpecification, supportsCatalogsInTableDefinitions, supportsCheckConstraintsInEndCreateStatements, supportsCheckInCreateStatements, supportsDefaultBeforeNullInColumnOptions, supportsDefaultKeywordInColumnOptions, supportsDefaultKeywordWithNotNullInColumnOptions, supportsDistinctWithSelectForUpdate, supportsEscapeExpressionInLikePredicate, supportsExistsSyntax, supportsPrimaryKeyInCreateStatements, supportsProjectionInTableReferenceJoins, supportsSchemasInTableDefinitions, supportsSettingBlobUsingSetString, supportsSettingClobUsingSetString, supportsStatementBatching, supportsStatementGetGeneratedKeys, supportsTransactionIsolationLevel, supportsUnionSyntax, supportsUniqueConstraintsInEndCreateStatements, tanMethod, toNumericExpression, toString, toStringExpression, useUnionAll
 
Methods inherited from class org.jpox.store.mapped.AbstractDatastoreAdapter
getAdapterTime, getDatastoreMajorVersion, getDatastoreMinorVersion, getIdentifierQuoteString, getMapping, getMapping, getMapping, getMapping, getMapping, getMappingManager, getMiliseconds, getTime, isBitReallyBoolean, isReservedKeyword, supportsQueryFetchSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jpox.store.rdbms.adapter.RDBMSAdapter
getIdentifierQuoteString
 
Methods inherited from interface org.jpox.store.mapped.DatastoreAdapter
getAdapterTime, getDatastoreMajorVersion, getDatastoreMinorVersion, getMapping, getMapping, getMapping, getMapping, getMappingManager, isBitReallyBoolean, isReservedKeyword, supportsQueryFetchSize
 

Field Detail

DB2_RESERVED_WORDS

public static final java.lang.String DB2_RESERVED_WORDS
A string containing the list of DB2 keywords This list is normally obtained dynamically from the driver using DatabaseMetaData.getSQLKeywords() Based on database DB2 version 7

See Also:
Constant Field Values
Constructor Detail

DB2Adapter

public DB2Adapter(java.sql.DatabaseMetaData metadata)
Constructs a DB2 adapter based on the given JDBC metadata.

Parameters:
metadata - the database metadata.
Method Detail

getVendorID

public java.lang.String getVendorID()
Specified by:
getVendorID in interface org.jpox.store.mapped.DatastoreAdapter
Overrides:
getVendorID in class org.jpox.store.mapped.AbstractDatastoreAdapter

getSchemaName

public java.lang.String getSchemaName(java.sql.Connection conn)
                               throws java.sql.SQLException
Description copied from class: DatabaseAdapter
Accessor for the Schema Name for this datastore.

Specified by:
getSchemaName in interface RDBMSAdapter
Overrides:
getSchemaName in class DatabaseAdapter
Parameters:
conn - Connection to the datastore
Returns:
The schema name
Throws:
java.sql.SQLException - Thrown if error occurs in determining the schema name.

closeConnection

public void closeConnection(java.sql.Connection conn)
                     throws java.sql.SQLException
Method to close a Connection to the datastore.

Specified by:
closeConnection in interface RDBMSAdapter
Overrides:
closeConnection in class DatabaseAdapter
Parameters:
conn - The connection
Throws:
java.sql.SQLException - Thrown if error occurs on the close.

getMaxConstraintNameLength

public int getMaxConstraintNameLength()
Accessor for the maximum constraint name length permitted on this datastore.

Specified by:
getMaxConstraintNameLength in interface RDBMSAdapter
Overrides:
getMaxConstraintNameLength in class DatabaseAdapter
Returns:
Max constraint name length

getMaxIndexNameLength

public int getMaxIndexNameLength()
Accessor for the maximum index name length permitted on this datastore.

Specified by:
getMaxIndexNameLength in interface RDBMSAdapter
Overrides:
getMaxIndexNameLength in class DatabaseAdapter
Returns:
Max index name length

supportsLockWithSelectForUpdate

public boolean supportsLockWithSelectForUpdate()
Whether this datastore supports locking using SELECT ... FOR UPDATE.

Specified by:
supportsLockWithSelectForUpdate in interface RDBMSAdapter
Overrides:
supportsLockWithSelectForUpdate in class DatabaseAdapter
Returns:
whether we support locking using SELECT ... FOR UPDATE.

supportsBooleanComparison

public boolean supportsBooleanComparison()
Description copied from class: DatabaseAdapter
Whether we support Boolean comparisons.

Specified by:
supportsBooleanComparison in interface org.jpox.store.mapped.expression.ExpressionSupportedFeaturesAdapter
Overrides:
supportsBooleanComparison in class DatabaseAdapter
Returns:
whether we support Boolean comparisons.

supportsDeferredConstraints

public boolean supportsDeferredConstraints()
Description copied from class: DatabaseAdapter
Whether this datastore supports deferred constraints.

Specified by:
supportsDeferredConstraints in interface RDBMSAdapter
Overrides:
supportsDeferredConstraints in class DatabaseAdapter
Returns:
whether we support deferred constraints.

supportsForeignKeyUpdateAction

public boolean supportsForeignKeyUpdateAction(ForeignKey.FKAction action)
Whether this datastore supports the specified foreign key update action

Specified by:
supportsForeignKeyUpdateAction in interface RDBMSAdapter
Overrides:
supportsForeignKeyUpdateAction in class DatabaseAdapter
Parameters:
action - The update action
Returns:
Whether it is supported

supportsForeignKeyDeleteAction

public boolean supportsForeignKeyDeleteAction(ForeignKey.FKAction action)
Whether this datastore supports the specified foreign key delete action

Specified by:
supportsForeignKeyDeleteAction in interface RDBMSAdapter
Overrides:
supportsForeignKeyDeleteAction in class DatabaseAdapter
Parameters:
action - The delete action
Returns:
Whether it is supported

supportsNullsInCandidateKeys

public boolean supportsNullsInCandidateKeys()
Description copied from class: DatabaseAdapter
Whether we support NULLs in candidate keys.

Specified by:
supportsNullsInCandidateKeys in interface RDBMSAdapter
Overrides:
supportsNullsInCandidateKeys in class DatabaseAdapter
Returns:
whether we support NULLs in candidate keys.

newTypeInfo

public TypeInfo newTypeInfo(java.sql.ResultSet rs)
Description copied from class: DatabaseAdapter
A factory for TypeInfo objects. This method should always be used instead of directly constructing TypeInfo objects in order to give the DatabaseAdapter an opportunity to modify and/or correct the metadata obtained from the JDBC driver. The type information object is constructed from the current row of the given result set. The ResultSet object passed must have been obtained from a call to DatabaseMetaData.getTypeInfo().

The constructor only retrieves the values from the current row; the caller is required to advance to the next row with ResultSet.next()

Overrides:
newTypeInfo in class DatabaseAdapter
Parameters:
rs - The result set returned from DatabaseMetaData.getTypeInfo().
Returns:
A TypeInfo object constructed from the current result set row, or null if the type indicated by this row should be excluded from use.

newColumnInfo

public ColumnInfo newColumnInfo(java.sql.ResultSet rs)
Description copied from class: DatabaseAdapter
A factory for ColumnInfo objects. This method should always be used instead of directly constructing ColumnInfo objects in order to give the DatabaseAdapter an opportunity to modify and/or correct the metadata obtained from the JDBC driver. The column information object is constructed from the current row of the given result set. The ResultSet object passed must have been obtained from a call to DatabaseMetaData.getColumns().

The constructor only retrieves the values from the current row; the caller is required to advance to the next row with ResultSet.next()

Specified by:
newColumnInfo in interface RDBMSAdapter
Overrides:
newColumnInfo in class DatabaseAdapter
Parameters:
rs - The result set returned from DatabaseMetaData.getColumns().
Returns:
The column info

newTableExpression

public org.jpox.store.mapped.expression.LogicSetExpression newTableExpression(org.jpox.store.mapped.expression.QueryExpression qs,
                                                                              org.jpox.store.mapped.DatastoreContainerObject table,
                                                                              org.jpox.store.mapped.DatastoreIdentifier rangeVar)
Description copied from class: DatabaseAdapter
Returns a new TableExpression object appropriate for this DBMS. This should be an instance of one of the three built-in styles of table expression: TableExprAsSubjoins is the default, which arguably produces the most readable SQL but doesn't work on all DBMS's. TableExprAsSubjoins should work anywhere, but may be less efficient.

Specified by:
newTableExpression in interface RDBMSAdapter
Overrides:
newTableExpression in class DatabaseAdapter
Parameters:
qs - The query statement in which the table expression will be included.
table - The main table in the expression.
rangeVar - The SQL alias, or "range variable", to assign to the expression or to the main table.
Returns:
The expression

modOperator

public org.jpox.store.mapped.expression.NumericExpression modOperator(org.jpox.store.mapped.expression.ScalarExpression operand1,
                                                                      org.jpox.store.mapped.expression.ScalarExpression operand2)
Method to generate a modulus expression. The binary % operator is said to yield the remainder of its operands from an implied division; the left-hand operand is the dividend and the right-hand operand is the divisor. This returns MOD(expr1, expr2).

Specified by:
modOperator in interface org.jpox.store.mapped.DatastoreAdapter
Specified by:
modOperator in interface org.jpox.store.mapped.expression.ExpressionOperatorAdapter
Overrides:
modOperator in class org.jpox.store.mapped.AbstractDatastoreAdapter
Parameters:
operand1 - the left expression
operand2 - the right expression
Returns:
The Expression for modulus

getUnlimitedLengthPrecisionValue

public int getUnlimitedLengthPrecisionValue(TypeInfo typeInfo)
Description copied from class: DatabaseAdapter
Returns the precision value to be used when creating string columns of "unlimited" length. Usually, if this value is needed it is provided in the database metadata (TypeInfo.precision). However, for some types in some databases the value must be computed specially.

Specified by:
getUnlimitedLengthPrecisionValue in interface RDBMSAdapter
Overrides:
getUnlimitedLengthPrecisionValue in class DatabaseAdapter
Parameters:
typeInfo - the typeInfo object for which the precision value is needed.
Returns:
the precision value to be used when creating the column, or -1 if no value should be used.

getDropTableStatement

public java.lang.String getDropTableStatement(org.jpox.store.mapped.DatastoreContainerObject table)
Description copied from class: DatabaseAdapter
Returns the appropriate SQL to drop the given table. It should return something like:

 DROP TABLE FOO CASCADE
 

Specified by:
getDropTableStatement in interface RDBMSAdapter
Overrides:
getDropTableStatement in class DatabaseAdapter
Parameters:
table - The table to drop.
Returns:
The text of the SQL statement.

lengthMethod

public org.jpox.store.mapped.expression.NumericExpression lengthMethod(org.jpox.store.mapped.expression.StringExpression str)
Description copied from class: DatabaseAdapter
Returns the appropriate SQL expression for the JDOQL String.length() method. It should return something like:

 CHAR_LENGTH(str)
 

Specified by:
lengthMethod in interface org.jpox.store.mapped.expression.ExpressionMethodAdapter
Overrides:
lengthMethod in class DatabaseAdapter
Parameters:
str - The argument to the length() method.
Returns:
The text of the SQL expression.

substringMethod

public org.jpox.store.mapped.expression.StringExpression substringMethod(org.jpox.store.mapped.expression.StringExpression str,
                                                                         org.jpox.store.mapped.expression.NumericExpression begin)
Description copied from class: DatabaseAdapter
Returns the appropriate SQL expression for the JDOQL String.substring(str,begin) method. It should return something like:

 SUBSTRING(str FROM begin)
 
Note that the value of begin is base 0(Java-style), while most SQL string functions use base 1.

Specified by:
substringMethod in interface org.jpox.store.mapped.expression.ExpressionMethodAdapter
Overrides:
substringMethod in class DatabaseAdapter
Parameters:
str - The first argument to the substring() method.
begin - The second argument to the substring() method.
Returns:
The text of the SQL expression.

substringMethod

public org.jpox.store.mapped.expression.StringExpression substringMethod(org.jpox.store.mapped.expression.StringExpression str,
                                                                         org.jpox.store.mapped.expression.NumericExpression begin,
                                                                         org.jpox.store.mapped.expression.NumericExpression end)
Description copied from class: DatabaseAdapter
Returns the appropriate SQL expression for the JDOQL String.substring(str,begin,end) method. It should return something like:

 SUBSTRING(str FROM begin FOR len)
 
Note that the value of begin is base 0 (Java-style), while most SQL string functions use base 1. Note also that an end position is given, while most SQL substring functions take a length.

Specified by:
substringMethod in interface org.jpox.store.mapped.expression.ExpressionMethodAdapter
Overrides:
substringMethod in class DatabaseAdapter
Parameters:
str - The first argument to the substring() method.
begin - The second argument to the substring() method.
end - The third argument to the substring() method.
Returns:
The text of the SQL expression.

trimMethod

public org.jpox.store.mapped.expression.StringExpression trimMethod(org.jpox.store.mapped.expression.StringExpression str,
                                                                    boolean leading,
                                                                    boolean trailing)
Returns the appropriate SQL expression for the java query "trim" method. It should return something like:
LTRIM(RTRIM(str))

Specified by:
trimMethod in interface org.jpox.store.mapped.expression.ExpressionMethodAdapter
Overrides:
trimMethod in class DatabaseAdapter
Parameters:
str - The first argument to the trim() method.
leading - Whether to trim leading spaces
trailing - Whether to trim trailing spaces
Returns:
The text of the SQL expression.

indexOfMethod

public org.jpox.store.mapped.expression.NumericExpression indexOfMethod(org.jpox.store.mapped.expression.ScalarExpression source,
                                                                        org.jpox.store.mapped.expression.ScalarExpression str,
                                                                        org.jpox.store.mapped.expression.NumericExpression from)
Returns the appropriate SQL expression for the JDOQL String.indexOf() method. It should return something like:

 LOCATE(str, substr [,pos])-1
 
since LOCATE returns the first character as position 1. Similarly the "pos" is based on the first position being 1.

Specified by:
indexOfMethod in interface org.jpox.store.mapped.expression.ExpressionMethodAdapter
Overrides:
indexOfMethod in class DatabaseAdapter
Parameters:
source - The expression we want to search.
str - The argument to the indexOf() method.
from - The from position
Returns:
The text of the SQL expression.

supportsNullsKeywordInColumnOptions

public boolean supportsNullsKeywordInColumnOptions()
Whether the database support NULLs in the column options for table creation. By default all columns are nullable in DB2, and the keyword NULL in the column options are not supported

Specified by:
supportsNullsKeywordInColumnOptions in interface RDBMSAdapter
Overrides:
supportsNullsKeywordInColumnOptions in class DatabaseAdapter
Returns:
whether the database support NULLs in the column options for table creation.

supportsIdentityFields

public boolean supportsIdentityFields()
Whether we support auto-increment fields.

Specified by:
supportsIdentityFields in interface org.jpox.store.mapped.DatastoreAdapter
Overrides:
supportsIdentityFields in class org.jpox.store.mapped.AbstractDatastoreAdapter
Returns:
whether we support auto-increment fields.

getAutoIncrementStmt

public java.lang.String getAutoIncrementStmt(Table table,
                                             java.lang.String columnName)
Accessor for the auto-increment sql statement for this datastore.

Specified by:
getAutoIncrementStmt in interface RDBMSAdapter
Overrides:
getAutoIncrementStmt in class DatabaseAdapter
Parameters:
table - Name of the table that the autoincrement is for
columnName - Name of the column that the autoincrement is for
Returns:
The statement for getting the latest auto-increment key

getAutoIncrementKeyword

public java.lang.String getAutoIncrementKeyword()
Accessor for the auto-increment keyword for generating DDLs (CREATE TABLEs...).

Specified by:
getAutoIncrementKeyword in interface RDBMSAdapter
Overrides:
getAutoIncrementKeyword in class DatabaseAdapter
Returns:
The keyword for a column using auto-increment

getContinuationString

public java.lang.String getContinuationString()
Continuation string to use where the SQL statement goes over more than 1 line. DB2 doesn't convert newlines into continuation characters and so we just provide a space so that it accepts the statement.

Overrides:
getContinuationString in class DatabaseAdapter
Returns:
Continuation string.

supportsSequences

public boolean supportsSequences()
Whether we support sequences.

Specified by:
supportsSequences in interface org.jpox.store.mapped.DatastoreAdapter
Specified by:
supportsSequences in interface RDBMSAdapter
Overrides:
supportsSequences in class org.jpox.store.mapped.AbstractDatastoreAdapter
Returns:
whether we support sequences.

getSequenceCreateStmt

public java.lang.String getSequenceCreateStmt(java.lang.String sequence_name,
                                              java.lang.String min,
                                              java.lang.String max,
                                              java.lang.String start,
                                              java.lang.String increment,
                                              java.lang.String cache_size)
Accessor for the sequence statement to create the sequence.

Specified by:
getSequenceCreateStmt in interface RDBMSAdapter
Overrides:
getSequenceCreateStmt in class DatabaseAdapter
Parameters:
sequence_name - Name of the sequence
min - Minimum value for the sequence
max - Maximum value for the sequence
start - Start value for the sequence
increment - Increment value for the sequence
cache_size - Cache size for the sequence
Returns:
The statement for getting the next id from the sequence

getSequenceNextStmt

public java.lang.String getSequenceNextStmt(java.lang.String sequence_name)
Accessor for the statement for getting the next id from the sequence for this datastore.

Specified by:
getSequenceNextStmt in interface RDBMSAdapter
Overrides:
getSequenceNextStmt in class DatabaseAdapter
Parameters:
sequence_name - Name of the sequence
Returns:
The statement for getting the next id for the sequence

toStringExpression

public org.jpox.store.mapped.expression.StringExpression toStringExpression(org.jpox.store.mapped.expression.StringLiteral expr)
A String conversion that converts a String literal to String expression. It will allow the String to only be evaluated at runtime. In SQL, it should compile something like:

 CAST(999999 AS VARCHAR(32672))
 

Specified by:
toStringExpression in interface org.jpox.store.mapped.expression.ExpressionConversionAdapter
Overrides:
toStringExpression in class DatabaseAdapter
Parameters:
expr - The NumericExpression
Returns:
the StringExpression

translateMethod

public org.jpox.store.mapped.expression.StringExpression translateMethod(org.jpox.store.mapped.expression.ScalarExpression expr,
                                                                         org.jpox.store.mapped.expression.ScalarExpression toExpr,
                                                                         org.jpox.store.mapped.expression.ScalarExpression fromExpr)
Method to translate all chars in this expression to the fromExpr which corresponds to toExpr.

Specified by:
translateMethod in interface org.jpox.store.mapped.expression.ExpressionMethodAdapter
Overrides:
translateMethod in class DatabaseAdapter
Returns:
The expression.

startsWithMethod

public org.jpox.store.mapped.expression.BooleanExpression startsWithMethod(org.jpox.store.mapped.expression.ScalarExpression source,
                                                                           org.jpox.store.mapped.expression.ScalarExpression str)
Method to handle the starts with operation.

Specified by:
startsWithMethod in interface org.jpox.store.mapped.expression.ExpressionMethodAdapter
Overrides:
startsWithMethod in class DatabaseAdapter
Parameters:
source - The expression with the searched string
str - The expression for the search string
Returns:
The expression.

concatOperator

public org.jpox.store.mapped.expression.ScalarExpression concatOperator(org.jpox.store.mapped.expression.ScalarExpression operand1,
                                                                        org.jpox.store.mapped.expression.ScalarExpression operand2)

If only one operand expression is of type String, then string conversion is performed on the other operand to produce a string at run time. The result is a reference to a String object (newly created, unless the expression is a compile-time constant expression (§15.28))that is the concatenation of the two operand strings. The characters of the left-hand operand precede the characters of the right-hand operand in the newly created string. If an operand of type String is null, then the string "null" is used instead of that operand. "null" is used instead of that operand.

Concatenates two or more character or binary strings, columns, or a combination of strings and column names into one expression (a string operator).

Specified by:
concatOperator in interface org.jpox.store.mapped.expression.ExpressionOperatorAdapter
Overrides:
concatOperator in class DatabaseAdapter
Parameters:
operand1 - the left expression
operand2 - the right expression
Returns:
The Expression for concatenation

endsWithMethod

public org.jpox.store.mapped.expression.BooleanExpression endsWithMethod(org.jpox.store.mapped.expression.ScalarExpression leftOperand,
                                                                         org.jpox.store.mapped.expression.ScalarExpression rightOperand)
Returns whether this string ends with the specified string.

Specified by:
endsWithMethod in interface org.jpox.store.mapped.expression.ExpressionMethodAdapter
Overrides:
endsWithMethod in class DatabaseAdapter
Parameters:
leftOperand - the source string
rightOperand - The string to compare against.
Returns:
Whether it ends with the string.


Copyright © -2008 . All Rights Reserved.