org.jpox.store.rdbms.adapter
Class SAPDBAdapter

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.SAPDBAdapter
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

public class SAPDBAdapter
extends DatabaseAdapter

Provides methods for adapting SQL language elements to the SAPDB/MaxDB database.

Version:
$Revision: 1.26 $

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jpox.store.rdbms.adapter.DatabaseAdapter
DatabaseAdapter.JDBCTypeInfo
 
Field Summary
 
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
SAPDBAdapter(java.sql.DatabaseMetaData metadata)
          Constructs an SAP DB adapter based on the given JDBC metadata.
 
Method Summary
 java.lang.String getAddCandidateKeyStatement(CandidateKey ck, org.jpox.store.mapped.IdentifierFactory factory)
          Returns the appropriate SQL to add a candidate key to its table.
 java.lang.String getAddForeignKeyStatement(ForeignKey fk, org.jpox.store.mapped.IdentifierFactory factory)
          Returns the appropriate SQL to add a foreign key to its table.
 java.lang.String getAddPrimaryKeyStatement(PrimaryKey pk, org.jpox.store.mapped.IdentifierFactory factory)
          Returns the appropriate SQL to add a primary key to its table.
 java.lang.String getSelectWithLockOption()
          The option to specify in "SELECT ...
 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.
 java.lang.String getVendorID()
           
 boolean isBitReallyBoolean()
          Accessor for whether a JDBC Types.BIT is really mapped in the datastore to a boolean field.
 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.QueryExpression newQueryStatement(org.jpox.store.mapped.DatastoreContainerObject table, org.jpox.ClassLoaderResolver clr)
          Accessor for a new query statement.
 org.jpox.store.mapped.expression.QueryExpression newQueryStatement(org.jpox.store.mapped.DatastoreContainerObject table, org.jpox.store.mapped.DatastoreIdentifier rangeVar, org.jpox.ClassLoaderResolver clr)
          Accessor for a new query statement.
 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.
 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 supportsAlterTableDropConstraint()
          Whether this datastore supports ALTER TABLE DROP constraints
 boolean supportsBooleanComparison()
          Whether we support Boolean comparisons.
 boolean supportsDeferredConstraints()
          Whether this datastore supports deferred constraints.
 boolean supportsForeignKeyUpdateAction(ForeignKey.FKAction action)
          Whether this datastore supports the specified foreign key update action.
 boolean supportsLockWithSelectForUpdate()
          Whether this datastore supports locking using SELECT ...
 boolean supportsSequences()
          Whether we support sequences.
 
Methods inherited from class org.jpox.store.rdbms.adapter.DatabaseAdapter
absMethod, acosMethod, addTypeInfo, asinMethod, atanMethod, cartersianProduct, ceilMethod, closeConnection, concatOperator, cosMethod, createIndexesBeforeForeignKeys, endsWithMethod, expMethod, floorMethod, getAddColumnStatement, getAutoIncrementKeyword, getAutoIncrementStmt, getCatalogName, getCatalogSeparator, getCharColumnsPaddedWithSpaces, getCheckConstraintForValues, getColumns, getColumns, getConnection, getContinuationString, getCreateIndexStatement, getCreateTableStatement, getCurrentDateMethod, getCurrentTimeMethod, getCurrentTimestampMethod, getDatastoreDateStatement, getDayMethod, getDriverMajorVersion, getDriverMinorVersion, getDropTableStatement, getDropViewStatement, getEscapeCharacter, getEscapedPatternExpression, getEscapePatternExpression, getExistingIndexes, getHourMethod, getInsertStatementForNoColumns, getMaxColumnNameLength, getMaxConstraintNameLength, getMaxForeignKeys, getMaxIndexes, getMaxIndexNameLength, getMaxTableNameLength, getMinuteMethod, getMonthMethod, getNewMappingManager, getNewUUIDFunction, getNonAnsiInnerJoinWhereClause, getNonAnsiLeftOuterJoinWhereClause, getNonAnsiRightOuterJoinWhereClause, getOperatorConcat, getPatternExpressionAnyCharacter, getPatternExpressionZeroMoreCharacters, getPlaceWithOptionAfterFromClause, getPlaceWithOptionWithinJoinClauses, getRangeByLimitSelectClause, getRangeByLimitWhereClause, getRangeByRowNumberColumn, getRequiredTransactionIsolationLevel, getSchemaName, getSecondMethod, getSelectNewUUIDStmt, getSupportsPersistOfUnassignedChar, getSurrogateForEmptyStrings, getTables, getTransactionIsolationForSchemaCreation, getTypeInfo, getUnlimitedLengthPrecisionValue, getYearMethod, includeOrderByColumnsInSelect, indexOfMethod, initialiseDatastore, isIdentityFieldDataType, isNullEqualsEmptyStrings, isSQLKeyword, isStoresLowerCaseIdentifiers, isStoresLowerCaseQuotedIdentifiers, isStoresMixedCaseIdentifiers, isStoresMixedCaseQuotedIdentifiers, isStoresUpperCaseIdentifiers, isStoresUpperCaseQuotedIdentifiers, isValidPrimaryKeyType, iteratorReservedWords, iteratorTypeInfo, loadDatastoreMapping, logConfiguration, logMethod, matchesMethod, newColumnInfo, newExportedKeyInfo, newForeignKeyInfo, newTypeInfo, parseKeywordList, requiresColumnDefaultsInitialising, setDefaultTypeInfoForJDBCType, sinMethod, sqrtMethod, startsWithMethod, supportsAlterTableDropForeignKeyConstraint, supportsAnalysisMethods, supportsAnsiJoinSyntax, supportsAutoIncrementColumnTypeSpecification, supportsAutoIncrementKeysNullSpecification, supportsCatalogsInTableDefinitions, supportsCheckConstraintsInEndCreateStatements, supportsCheckInCreateStatements, supportsDefaultBeforeNullInColumnOptions, supportsDefaultKeywordInColumnOptions, supportsDefaultKeywordWithNotNullInColumnOptions, supportsDistinctWithSelectForUpdate, supportsEscapeExpressionInLikePredicate, supportsExistsSyntax, supportsForeignKeyDeleteAction, supportsNullsInCandidateKeys, supportsNullsKeywordInColumnOptions, supportsPrimaryKeyInCreateStatements, supportsProjectionInTableReferenceJoins, supportsSchemasInTableDefinitions, supportsSettingBlobUsingSetString, supportsSettingClobUsingSetString, supportsStatementBatching, supportsStatementGetGeneratedKeys, supportsTransactionIsolationLevel, supportsUnionSyntax, supportsUniqueConstraintsInEndCreateStatements, tanMethod, toNumericExpression, toString, toStringExpression, toStringExpression, translateMethod, trimMethod, useUnionAll
 
Methods inherited from class org.jpox.store.mapped.AbstractDatastoreAdapter
getAdapterTime, getDatastoreMajorVersion, getDatastoreMinorVersion, getIdentifierQuoteString, getMapping, getMapping, getMapping, getMapping, getMapping, getMappingManager, getMiliseconds, getTime, isReservedKeyword, modOperator, supportsIdentityFields, 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, isReservedKeyword, modOperator, supportsIdentityFields, supportsQueryFetchSize
 

Constructor Detail

SAPDBAdapter

public SAPDBAdapter(java.sql.DatabaseMetaData metadata)
Constructs an SAP DB 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

isBitReallyBoolean

public boolean isBitReallyBoolean()
Accessor for whether a JDBC Types.BIT is really mapped in the datastore to a boolean field.

Specified by:
isBitReallyBoolean in interface org.jpox.store.mapped.DatastoreAdapter
Overrides:
isBitReallyBoolean in class org.jpox.store.mapped.AbstractDatastoreAdapter
Returns:
Whether it is really a boolean

supportsAlterTableDropConstraint

public boolean supportsAlterTableDropConstraint()
Description copied from class: DatabaseAdapter
Whether this datastore supports ALTER TABLE DROP constraints

Specified by:
supportsAlterTableDropConstraint in interface RDBMSAdapter
Overrides:
supportsAlterTableDropConstraint in class DatabaseAdapter
Returns:
whether we support ALTER TABLE DROP constraints

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.

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.

getSelectWithLockOption

public java.lang.String getSelectWithLockOption()
The option to specify in "SELECT ... WITH (option)" to lock instances Null if not supported.

Specified by:
getSelectWithLockOption in interface RDBMSAdapter
Overrides:
getSelectWithLockOption in class DatabaseAdapter
Returns:
The option to specify with "SELECT ... WITH (option)"

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

newQueryStatement

public org.jpox.store.mapped.expression.QueryExpression newQueryStatement(org.jpox.store.mapped.DatastoreContainerObject table,
                                                                          org.jpox.store.mapped.DatastoreIdentifier rangeVar,
                                                                          org.jpox.ClassLoaderResolver clr)
Description copied from class: DatabaseAdapter
Accessor for a new query statement.

Specified by:
newQueryStatement in interface org.jpox.store.mapped.DatastoreAdapter
Overrides:
newQueryStatement in class DatabaseAdapter
Parameters:
table - The table to query
rangeVar - A range variable for the query
clr - The ClassLoaderResolver
Returns:
The Query Statement

newQueryStatement

public org.jpox.store.mapped.expression.QueryExpression newQueryStatement(org.jpox.store.mapped.DatastoreContainerObject table,
                                                                          org.jpox.ClassLoaderResolver clr)
Description copied from class: DatabaseAdapter
Accessor for a new query statement.

Specified by:
newQueryStatement in interface org.jpox.store.mapped.DatastoreAdapter
Overrides:
newQueryStatement in class DatabaseAdapter
Parameters:
table - The table to query
clr - The ClassLoaderResolver
Returns:
The Query Statement

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

getAddPrimaryKeyStatement

public java.lang.String getAddPrimaryKeyStatement(PrimaryKey pk,
                                                  org.jpox.store.mapped.IdentifierFactory factory)
Description copied from class: DatabaseAdapter
Returns the appropriate SQL to add a primary key to its table. It should return something like:

 ALTER TABLE FOO ADD CONSTRAINT FOO_PK PRIMARY KEY (BAR)
 ALTER TABLE FOO ADD PRIMARY KEY (BAR)
 

Specified by:
getAddPrimaryKeyStatement in interface RDBMSAdapter
Overrides:
getAddPrimaryKeyStatement in class DatabaseAdapter
Parameters:
pk - An object describing the primary key.
factory - Identifier factory
Returns:
The text of the SQL statement.

getAddCandidateKeyStatement

public java.lang.String getAddCandidateKeyStatement(CandidateKey ck,
                                                    org.jpox.store.mapped.IdentifierFactory factory)
Description copied from class: DatabaseAdapter
Returns the appropriate SQL to add a candidate key to its table. It should return something like:

 ALTER TABLE FOO ADD CONSTRAINT FOO_CK UNIQUE (BAZ)
 ALTER TABLE FOO ADD UNIQUE (BAZ)
 

Specified by:
getAddCandidateKeyStatement in interface RDBMSAdapter
Overrides:
getAddCandidateKeyStatement in class DatabaseAdapter
Parameters:
ck - An object describing the candidate key.
factory - Identifier factory
Returns:
The text of the SQL statement.

getAddForeignKeyStatement

public java.lang.String getAddForeignKeyStatement(ForeignKey fk,
                                                  org.jpox.store.mapped.IdentifierFactory factory)
Description copied from class: DatabaseAdapter
Returns the appropriate SQL to add a foreign key to its table. It should return something like:

 ALTER TABLE FOO ADD CONSTRAINT FOO_FK1 FOREIGN KEY (BAR, BAZ) REFERENCES ABC (COL1, COL2)
 ALTER TABLE FOO ADD FOREIGN KEY (BAR, BAZ) REFERENCES ABC (COL1, COL2)
 

Specified by:
getAddForeignKeyStatement in interface RDBMSAdapter
Overrides:
getAddForeignKeyStatement in class DatabaseAdapter
Parameters:
fk - An object describing the foreign key.
factory - Identifier factory
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.

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


Copyright © -2008 . All Rights Reserved.