org.jpox.store.rdbms.adapter
Class McKoiAdapter

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.McKoiAdapter
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 McKoiAdapter
extends DatabaseAdapter

Provides methods for adapting SQL language elements to the McKoi database Server database.

Version:
$Revision: 1.19 $

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
McKoiAdapter(java.sql.DatabaseMetaData metadata)
          Constructs a Hypersonic SQL adapter based on the given JDBC metadata.
 
Method Summary
 java.lang.String getAddColumnStatement(org.jpox.store.mapped.DatastoreContainerObject table, Column col)
          Accessor for the SQL statement to add a column to a table.
 java.sql.Connection getConnection(ConnectionProvider connProvider, javax.sql.DataSource[] ds, int isolationLevel)
          Accessor for a Connection to the datastore.
 java.lang.String getDropTableStatement(org.jpox.store.mapped.DatastoreContainerObject table)
          Returns the appropriate SQL to drop the given table.
 int getMaxColumnNameLength()
          Accessor for the maximum column name length permitted on this datastore.
 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.
 int getMaxTableNameLength()
          Accessor for the maximum table name length permitted on 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.
 java.lang.String getVendorID()
           
 boolean isSQLKeyword(java.lang.String word)
          Tests if a given string is a SQL key word.
 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.LogicSetExpression newTableExpression(org.jpox.store.mapped.expression.QueryExpression qs, org.jpox.store.mapped.DatastoreContainerObject table, org.jpox.store.mapped.DatastoreIdentifier rangeVar)
          Return a new TableExpression appropriate to MySQL.
 TypeInfo newTypeInfo(java.sql.ResultSet rs)
          Factory for TypeInfo objects.
 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 supportsEscapeExpressionInLikePredicate()
          Whether this datastore supports the use of the escape expression in like predicates
 boolean supportsSequences()
          Whether we support sequences.
 boolean supportsTransactionIsolationLevel(int isolationLevel)
          Accessor for whether the adapter supports the transaction isolation level
 boolean useUnionAll()
          Union combines the results of two or more queries into a single result set.
 
Methods inherited from class org.jpox.store.rdbms.adapter.DatabaseAdapter
absMethod, acosMethod, addTypeInfo, asinMethod, atanMethod, cartersianProduct, ceilMethod, closeConnection, concatOperator, cosMethod, createIndexesBeforeForeignKeys, endsWithMethod, expMethod, floorMethod, getAddCandidateKeyStatement, getAddForeignKeyStatement, getAddPrimaryKeyStatement, getAutoIncrementKeyword, getAutoIncrementStmt, getCatalogName, getCatalogSeparator, getCharColumnsPaddedWithSpaces, getCheckConstraintForValues, getColumns, getColumns, getContinuationString, getCreateIndexStatement, getCreateTableStatement, getCurrentDateMethod, getCurrentTimeMethod, getCurrentTimestampMethod, getDatastoreDateStatement, getDayMethod, getDriverMajorVersion, getDriverMinorVersion, getDropViewStatement, getEscapeCharacter, getEscapedPatternExpression, getEscapePatternExpression, getExistingIndexes, getHourMethod, getInsertStatementForNoColumns, getMaxForeignKeys, getMaxIndexes, getMinuteMethod, getMonthMethod, getNewMappingManager, getNewUUIDFunction, getNonAnsiInnerJoinWhereClause, getNonAnsiLeftOuterJoinWhereClause, getNonAnsiRightOuterJoinWhereClause, getOperatorConcat, getPatternExpressionAnyCharacter, getPatternExpressionZeroMoreCharacters, getPlaceWithOptionAfterFromClause, getPlaceWithOptionWithinJoinClauses, getRangeByLimitSelectClause, getRangeByLimitWhereClause, getRangeByRowNumberColumn, getRequiredTransactionIsolationLevel, getSchemaName, getSecondMethod, getSelectNewUUIDStmt, getSelectWithLockOption, getSupportsPersistOfUnassignedChar, getSurrogateForEmptyStrings, getTables, getTransactionIsolationForSchemaCreation, getTypeInfo, getUnlimitedLengthPrecisionValue, getYearMethod, includeOrderByColumnsInSelect, indexOfMethod, initialiseDatastore, isIdentityFieldDataType, isNullEqualsEmptyStrings, isStoresLowerCaseIdentifiers, isStoresLowerCaseQuotedIdentifiers, isStoresMixedCaseIdentifiers, isStoresMixedCaseQuotedIdentifiers, isStoresUpperCaseIdentifiers, isStoresUpperCaseQuotedIdentifiers, isValidPrimaryKeyType, iteratorReservedWords, iteratorTypeInfo, loadDatastoreMapping, logConfiguration, logMethod, matchesMethod, newColumnInfo, newExportedKeyInfo, newForeignKeyInfo, newQueryStatement, newQueryStatement, parseKeywordList, requiresColumnDefaultsInitialising, setDefaultTypeInfoForJDBCType, sinMethod, sqrtMethod, startsWithMethod, supportsAlterTableDropConstraint, supportsAlterTableDropForeignKeyConstraint, supportsAnalysisMethods, supportsAnsiJoinSyntax, supportsAutoIncrementColumnTypeSpecification, supportsAutoIncrementKeysNullSpecification, supportsBooleanComparison, supportsCatalogsInTableDefinitions, supportsCheckConstraintsInEndCreateStatements, supportsCheckInCreateStatements, supportsDefaultBeforeNullInColumnOptions, supportsDefaultKeywordInColumnOptions, supportsDefaultKeywordWithNotNullInColumnOptions, supportsDeferredConstraints, supportsDistinctWithSelectForUpdate, supportsExistsSyntax, supportsForeignKeyDeleteAction, supportsForeignKeyUpdateAction, supportsLockWithSelectForUpdate, supportsNullsInCandidateKeys, supportsNullsKeywordInColumnOptions, supportsPrimaryKeyInCreateStatements, supportsProjectionInTableReferenceJoins, supportsSchemasInTableDefinitions, supportsSettingBlobUsingSetString, supportsSettingClobUsingSetString, supportsStatementBatching, supportsStatementGetGeneratedKeys, supportsUnionSyntax, supportsUniqueConstraintsInEndCreateStatements, tanMethod, toNumericExpression, toString, toStringExpression, toStringExpression, translateMethod, trimMethod
 
Methods inherited from class org.jpox.store.mapped.AbstractDatastoreAdapter
getAdapterTime, getDatastoreMajorVersion, getDatastoreMinorVersion, getIdentifierQuoteString, getMapping, getMapping, getMapping, getMapping, getMapping, getMappingManager, getMiliseconds, getTime, isBitReallyBoolean, 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, isBitReallyBoolean, isReservedKeyword, modOperator, supportsIdentityFields, supportsQueryFetchSize
 

Constructor Detail

McKoiAdapter

public McKoiAdapter(java.sql.DatabaseMetaData metadata)
Constructs a Hypersonic SQL 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

isSQLKeyword

public boolean isSQLKeyword(java.lang.String word)
Description copied from class: DatabaseAdapter
Tests if a given string is a SQL key word.

The list of key words tested against is defined to contain all SQL/92 key words, plus any additional key words reported by the JDBC driver for this adapter via DatabaseMetaData.getSQLKeywords().

In general, use of a SQL key word as an identifier should be avoided. SQL/92 key words are divided into reserved and non-reserved words. If a reserved word is used as an identifier it must be quoted with double quotes. Strictly speaking, the same is not true of non-reserved words. However, as C.J. Date writes in A Guide To The SQL Standard :

The rule by which it is determined within the standard that one key word needs to be reserved while another need not is not clear to this writer. In practice, it is probably wise to treat all key words as reserved.

Specified by:
isSQLKeyword in interface RDBMSAdapter
Overrides:
isSQLKeyword in class DatabaseAdapter
Parameters:
word - The word to test.
Returns:
true if word is a SQL key word for this DBMS. The comparison is case-insensitive.
See Also:
SQLConstants

getMaxTableNameLength

public int getMaxTableNameLength()
Accessor for the maximum table name length permitted on this datastore.

Specified by:
getMaxTableNameLength in interface RDBMSAdapter
Overrides:
getMaxTableNameLength in class DatabaseAdapter
Returns:
Max table name length

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

getMaxColumnNameLength

public int getMaxColumnNameLength()
Accessor for the maximum column name length permitted on this datastore.

Specified by:
getMaxColumnNameLength in interface RDBMSAdapter
Overrides:
getMaxColumnNameLength in class DatabaseAdapter
Returns:
Max column name length

getAddColumnStatement

public java.lang.String getAddColumnStatement(org.jpox.store.mapped.DatastoreContainerObject table,
                                              Column col)
Accessor for the SQL statement to add a column to a table.

Specified by:
getAddColumnStatement in interface RDBMSAdapter
Overrides:
getAddColumnStatement in class DatabaseAdapter
Parameters:
table - The table
col - The column
Returns:
The SQL necessary to add the column

newTypeInfo

public TypeInfo newTypeInfo(java.sql.ResultSet rs)
Factory for TypeInfo objects.

Overrides:
newTypeInfo in class DatabaseAdapter
Parameters:
rs - The ResultSet from DatabaseMetaData.getTypeInfo().
Returns:
A TypeInfo object.

supportsEscapeExpressionInLikePredicate

public boolean supportsEscapeExpressionInLikePredicate()
Whether this datastore supports the use of the escape expression in like predicates

Specified by:
supportsEscapeExpressionInLikePredicate in interface org.jpox.store.mapped.expression.ExpressionSupportedFeaturesAdapter
Overrides:
supportsEscapeExpressionInLikePredicate in class DatabaseAdapter
Returns:
whether we can use the escape expression in like predicates

supportsTransactionIsolationLevel

public boolean supportsTransactionIsolationLevel(int isolationLevel)
Accessor for whether the adapter supports the transaction isolation level

Specified by:
supportsTransactionIsolationLevel in interface RDBMSAdapter
Overrides:
supportsTransactionIsolationLevel in class DatabaseAdapter
Parameters:
isolationLevel - the isolation level
Returns:
Whether the transaction isolation level setting is supported.

getConnection

public java.sql.Connection getConnection(ConnectionProvider connProvider,
                                         javax.sql.DataSource[] ds,
                                         int isolationLevel)
                                  throws java.sql.SQLException
Accessor for a Connection to the datastore.

Specified by:
getConnection in interface RDBMSAdapter
Overrides:
getConnection in class DatabaseAdapter
Parameters:
connProvider - the ConnectionProvider
ds - The data source. Possible to have more than one datasource for failover
isolationLevel - The level of transaction isolation
Returns:
The Connection
Throws:
java.sql.SQLException - Thrown when an error occurs in the creation. Up to and including 1.0.2, McKoi supports only Connection.TRANSACTION_SERIALIZABLE.

getDropTableStatement

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

 DROP TABLE FOO
 

Specified by:
getDropTableStatement in interface RDBMSAdapter
Overrides:
getDropTableStatement in class DatabaseAdapter
Parameters:
table - The table to drop.
Returns:
The text of the SQL 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)
Return a new TableExpression appropriate to MySQL. MySQL does not support the TableExprAsSubjoins so instead we use TableExprAsJoins.

Specified by:
newTableExpression in interface RDBMSAdapter
Overrides:
newTableExpression in class DatabaseAdapter
Parameters:
qs - The QueryStatement to add the expression to
table - The table in the expression
rangeVar - range variable to assign to the expression.
Returns:
The expression.

useUnionAll

public boolean useUnionAll()
Union combines the results of two or more queries into a single result set. Union include only distinct rows and Union all may include duplicates.

Specified by:
useUnionAll in interface RDBMSAdapter
Overrides:
useUnionAll in class DatabaseAdapter
Returns:
Whether to use UNION ALL instead of UNION

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.