org.jpox.store.rdbms.adapter
Interface RDBMSAdapter

All Superinterfaces:
DatastoreAdapter, ExpressionConversionAdapter, ExpressionLogicSetAdapter, ExpressionMethodAdapter, ExpressionOperatorAdapter, ExpressionPatternAdapter, ExpressionSupportedFeaturesAdapter
All Known Implementing Classes:
DatabaseAdapter

public interface RDBMSAdapter
extends DatastoreAdapter

Adapter for relational databases


Field Summary
 
Fields inherited from interface org.jpox.store.DatastoreAdapter
IDENTIFIER_LOWER_CASE, IDENTIFIER_LOWER_CASE_QUOTED, IDENTIFIER_MIXED_CASE, IDENTIFIER_MIXED_CASE_QUOTED, IDENTIFIER_UPPER_CASE, IDENTIFIER_UPPER_CASE_QUOTED
 
Method Summary
 boolean createIndexesBeforeForeignKeys()
          Whether to create indexes before foreign keys.
 java.lang.String getAddCandidateKeyStatement(CandidateKey ck)
          Returns the appropriate SQL to add a candidate key to its table.
 java.lang.String getAddColumnStatement(DatastoreContainerObject table, Column col)
          Accessor for the SQL statement to add a column to a table.
 java.lang.String getAddForeignKeyStatement(ForeignKey fk)
          Returns the appropriate SQL to add a foreign key to its table.
 java.lang.String getAddPrimaryKeyStatement(PrimaryKey pk)
          Returns the appropriate SQL to add a primary key to its table.
 java.lang.String getAutoIncrementKeyword()
          Accessor for the auto-increment/identity keyword for generating DDLs.
 java.lang.String getAutoIncrementStmt(java.lang.String tableName, java.lang.String columnName)
          Accessor for the auto-increment/identity sql statement for this datastore.
 java.lang.String getCatalogName(java.sql.Connection conn)
          Accessor for the Catalog Name for this datastore.
 java.lang.String getCatalogSeparator()
          Accessor for the catalog separator.
 java.sql.ResultSet getColumns(java.sql.Connection conn, java.lang.String catalog, java.lang.String schema, java.lang.String table)
          Accessor for table and column information for a catalog/schema in this datastore.
 java.sql.ResultSet getColumns(java.sql.Connection conn, java.lang.String catalog, java.lang.String schema, java.lang.String table, java.lang.String columnNamePattern)
          Accessor for table and column information for a catalog/schema in this datastore.
 java.lang.String getCreateIndexStatement(Index idx)
          Returns the appropriate SQL to add an index to its table.
 java.lang.String getCreateTableStatement(TableImpl table, Column[] columns, java.util.Properties props)
          Returns the appropriate SQL to create the given table having the given columns.
 java.lang.String getDropTableStatement(DatastoreContainerObject table)
          Returns the appropriate SQL to drop the given table.
 java.lang.String getDropViewStatement(ViewImpl view)
          Returns the appropriate SQL to drop the given view.
 java.sql.ResultSet getExistingIndexes(java.sql.Connection conn, java.sql.DatabaseMetaData dmd, java.lang.String catalog, java.lang.String schema, java.lang.String table)
          Provide the existing indexes in the database for the table
 java.lang.String getIdentifierQuoteString()
          Accessor for an identifier quote string.
 java.lang.String getInsertStatementForNoColumns(Table table)
          Method to retutn the INSERT statement to use when inserting into a table that has no columns specified.
 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 getMaxForeignKeys()
          Accessor for the maximum foreign keys by table permitted datastore.
 int getMaxIndexes()
          Accessor for the maximum indexes by schema permitted 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 getNonAnsiInnerJoinWhereClause(java.lang.String col1, java.lang.String col2)
          Accessor for the WHERE clause to add to provide an INNER JOIN using non-ANSI syntax.
 java.lang.String getNonAnsiLeftOuterJoinWhereClause(java.lang.String col1, java.lang.String col2)
          Accessor for the WHERE clause to add to provide a LEFT OUTER JOIN using non-ANSI syntax.
 boolean getPlaceWithOptionAfterFromClause()
          Determines whether the getSelectWithLockOption() is to be placed right before the FROM clause, or at the end of the statement
 boolean getPlaceWithOptionWithinJoinClauses()
          Determines whether lock option has to be placed within JOIN clauses as well.
 java.lang.String getRangeByLimitSelectClause(long offset, long count)
          Method to return the SQL to append to the SELECT clause of a SELECT statement to handle restriction of ranges using the LIMIT keyword.
 java.lang.String getRangeByLimitWhereClause(long offset, long count)
          Method to return the SQL to append to the WHERE clause of a SELECT statement to handle restriction of ranges using the LIMIT keyword.
 java.lang.String getRangeByRowNumberColumn()
          Method to return the column name to use when handling ranges via a rownumber on the select.
 java.lang.String getSchemaName(java.sql.Connection conn)
          Accessor for the Schema Name for this datastore.
 java.lang.String getSelectNewUUIDStmt()
          The function to creates a unique value of type uniqueidentifier.
 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 create statement for this datastore.
 java.lang.String getSequenceNextStmt(java.lang.String sequence_name)
          Accessor for the sequence statement to get the next id for this datastore.
 java.lang.String getSurrogateForEmptyStrings()
          Some databases, Oracle, treats an empty string (0 length) equals null
 java.sql.ResultSet getTables(java.sql.Connection conn, java.lang.String catalog, java.lang.String schema)
          Accessor for table information for a catalog/schema in this datastore.
 int getTransactionIsolationForSchemaCreation()
          Accessor for the transaction isolation level to use during schema creation.
 TypeInfo getTypeInfo(int dataType)
          Returns type information for the database type that best implements the given JDBC type.
 int getUnlimitedLengthPrecisionValue(TypeInfo typeInfo)
          Returns the precision value to be used when creating string columns of "unlimited" length.
 boolean includeOrderByColumnsInSelect()
          Whether to include ORDER BY columns in a SELECT.
 boolean isBitReallyBoolean()
          Accessor for whether a JDBC Types.BIT is really mapped in the datastore to a boolean field.
 boolean isNullEqualsEmptyStrings()
          Some databases, Oracle, treats an empty string (0 length) equals null
 boolean isSQLKeyword(java.lang.String word)
          Tests if a given string is a SQL key word.
 boolean isValidPrimaryKeyType(int datatype)
          Method to return whether the specified JDBC type is valid for use in a PrimaryKey.
 java.util.Iterator iteratorReservedWords()
          Iterator for the reserved words constructed from the method DataBaseMetaData.getSQLKeywords + standard SQL reserved words
 java.util.Iterator iteratorTypeInfo()
          Iterator for the TypeInfo objects constructed from the method DataBaseMetaData.getTypeInfo
 ColumnInfo newColumnInfo(java.sql.ResultSet rs)
          A factory for ColumnInfo objects.
 ForeignKeyInfo newForeignKeyInfo(java.sql.ResultSet rs)
          A factory for ForeignKeyInfo objects.
 LogicSetExpression newTableExpression(QueryExpression qs, DatastoreContainerObject table, DatastoreIdentifier rangeVar)
          Returns a new TableExpression object appropriate for this DBMS.
 boolean requiresColumnDefaultsInitialising()
          Accessor for whether the column defaults need initialising for this datastore
 boolean supportsAlterTableDropConstraint()
          Whether this datastore supports ALTER TABLE DROP constraints
 boolean supportsAlterTableDropForeignKeyConstraint()
          Whether this datastore supports ALTER TABLE DROP FOREIGN KEY constraints
 boolean supportsAnsiJoinSyntax()
          Accessor for whether the RDBMS supports ANSI join syntax.
 boolean supportsAutoIncrementColumnTypeSpecification()
          Whether we support auto-increment/identity keys with column type specification.
 boolean supportsAutoIncrementKeysNullSpecification()
          Whether we support auto-increment/identity keys with nullability specification.
 boolean supportsCatalogsInTableDefinitions()
          Whether this datastore supports the use of the catalog name in SQL table definitions (DDL).
 boolean supportsCheckInCreateStatements()
          Whether this datastore supports the use of CHECK in CREATE TABLE statements (DDL).
 boolean supportsDefaultBeforeNullInColumnOptions()
          Whether any DEFAULT tag will be before any NULL/NOT NULL in the column options.
 boolean supportsDefaultKeywordInColumnOptions()
          Whether we support DEFAULT tag in CREATE TABLE statements
 boolean supportsDefaultKeywordWithNotNullInColumnOptions()
          Whether we support DEFAULT tag together with NOT NULL in CREATE TABLE statements.
 boolean supportsDeferredConstraints()
          Whether this datastore supports deferred constraints.
 boolean supportsDistinctWithSelectForUpdate()
          Whether this datastore supports using DISTINCT when using SELECT ...
 boolean supportsExistsSyntax()
          Whether the RDBMS supports use of EXISTS syntax.
 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 supportsLockWithSelectForUpdate()
          Whether this datastore supports 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 supportsPrimaryKeyInCreateStatements()
          Whether the datastore supports specification of the primary key in CREATE TABLE statements.
 boolean supportsSchemasInTableDefinitions()
          Whether this datastore supports the use of the schema name in SQL table definitions (DDL).
 boolean supportsSequences()
          Whether we support sequences.
 boolean supportsSettingBlobUsingSetString()
          Accessor for whether setting a BLOB value allows use of PreparedStatement.setString()
 boolean supportsSettingClobUsingSetString()
          Accessor for whether setting a CLOB value allows use of PreparedStatement.setString()
 boolean supportsStatementGetGeneratedKeys()
          Whether the datastore supports Statement.getGeneratedKeys()
 boolean supportsUnionSyntax()
          Whether the RDBMS supports use of UNION syntax.
 boolean supportsUniqueConstraintsInEndCreateStatements()
          Whether this datastore supports the use of UNIQUE after the column definitions in CREATE TABLE statements (DDL).
 boolean useUnionAll()
          Union combines the results of two or more queries into a single result set.
 
Methods inherited from interface org.jpox.store.DatastoreAdapter
closeConnection, getAdapterTime, getConnection, getDatastoreMajorVersion, getDatastoreMinorVersion, getDictionary, getIdentifierCase, getIdentifierInAdapterCase, getMapping, getMapping, getMapping, getMapping, getMappingManager, getVendorID, initialiseDatastore, isAutoIncrementingDataType, isReservedKeyword, loadDatastoreMapping, modOperator, newQueryStatement, newQueryStatement, supportsAutoIncrementFields, supportsQueryFetchSizeLowerThanOne, toString
 
Methods inherited from interface org.jpox.store.expression.ExpressionConversionAdapter
toNumericExpression, toStringExpression, toStringExpression
 
Methods inherited from interface org.jpox.store.expression.ExpressionOperatorAdapter
concatOperator, getOperatorConcat
 
Methods inherited from interface org.jpox.store.expression.ExpressionMethodAdapter
absMethod, acosMethod, asinMethod, atanMethod, ceilMethod, cosMethod, endsWithMethod, expMethod, floorMethod, getDayMethod, getHourMethod, getMinuteMethod, getMonthMethod, getSecondMethod, getYearMethod, indexOfMethod, lengthMethod, logMethod, sinMethod, sqrtMethod, startsWithMethod, substringMethod, substringMethod, tanMethod, trimMethod
 
Methods inherited from interface org.jpox.store.expression.ExpressionSupportedFeaturesAdapter
supportsBooleanComparison, supportsEscapeExpressionInLikePredicate
 
Methods inherited from interface org.jpox.store.expression.ExpressionPatternAdapter
getEscapeCharacter, getEscapedPatternExpression, getEscapePatternExpression, getPatternExpressionAnyCharacter, getPatternExpressionZeroMoreCharacters
 
Methods inherited from interface org.jpox.store.expression.ExpressionLogicSetAdapter
cartersianProduct
 

Method Detail

getRangeByLimitSelectClause

public java.lang.String getRangeByLimitSelectClause(long offset,
                                                    long count)
Method to return the SQL to append to the SELECT clause of a SELECT statement to handle restriction of ranges using the LIMIT keyword. Defaults to an empty string (not supported). SELECT {LIMIT} params

Parameters:
offset - The offset to return from
count - The number of items to return
Returns:
The SQL to append to allow for ranges using LIMIT.

getRangeByLimitWhereClause

public java.lang.String getRangeByLimitWhereClause(long offset,
                                                   long count)
Method to return the SQL to append to the WHERE clause of a SELECT statement to handle restriction of ranges using the LIMIT keyword. Defaults to an empty string (not supported). SELECT param ... WHERE {LIMIT}

Parameters:
offset - The offset to return from
count - The number of items to return
Returns:
The SQL to append to allow for ranges using LIMIT.

getRangeByRowNumberColumn

public java.lang.String getRangeByRowNumberColumn()
Method to return the column name to use when handling ranges via a rownumber on the select. Defaults to an empty string (not supported).

Returns:
The row number column.

getMaxForeignKeys

public int getMaxForeignKeys()
Accessor for the maximum foreign keys by table permitted datastore.

Returns:
Max table name length

getMaxIndexes

public int getMaxIndexes()
Accessor for the maximum indexes by schema permitted datastore.

Returns:
Max table name length

getCatalogSeparator

public java.lang.String getCatalogSeparator()
Accessor for the catalog separator.

Returns:
Catalog separator string.

newColumnInfo

public ColumnInfo newColumnInfo(java.sql.ResultSet rs)
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()

Parameters:
rs - The result set returned from DatabaseMetaData.getColumns().
Returns:
The column info

newForeignKeyInfo

public ForeignKeyInfo newForeignKeyInfo(java.sql.ResultSet rs)
A factory for ForeignKeyInfo objects. This method should always be used instead of directly constructing ForeignKeyInfo 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.getImportedKeys() or DatabaseMetaData.getExportedKeys().

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

Parameters:
rs - The result set returned from DatabaseMetaData.get??portedKeys()
Returns:
The foreign key info

getIdentifierQuoteString

public java.lang.String getIdentifierQuoteString()
Accessor for an identifier quote string.

Specified by:
getIdentifierQuoteString in interface DatastoreAdapter
Returns:
Identifier quote string.

supportsCatalogsInTableDefinitions

public boolean supportsCatalogsInTableDefinitions()
Whether this datastore supports the use of the catalog name in SQL table definitions (DDL).

Returns:
whether we can use the catalog name in DDL

supportsSchemasInTableDefinitions

public boolean supportsSchemasInTableDefinitions()
Whether this datastore supports the use of the schema name in SQL table definitions (DDL).

Returns:
whether we can use the schema name in DDL

supportsUnionSyntax

public boolean supportsUnionSyntax()
Whether the RDBMS supports use of UNION syntax.

Returns:
Whether UNION is supported.

supportsExistsSyntax

public boolean supportsExistsSyntax()
Whether the RDBMS supports use of EXISTS syntax.

Returns:
Whether EXISTS is supported.

getColumns

public java.sql.ResultSet getColumns(java.sql.Connection conn,
                                     java.lang.String catalog,
                                     java.lang.String schema,
                                     java.lang.String table)
                              throws java.sql.SQLException
Accessor for table and column information for a catalog/schema in this datastore.

Parameters:
conn - Connection to use
catalog - The catalog (null if none)
schema - The schema (null if none)
table - The table (null if all)
Returns:
ResultSet containing the table/column information
Throws:
java.sql.SQLException - Thrown if an error occurs

getColumns

public java.sql.ResultSet getColumns(java.sql.Connection conn,
                                     java.lang.String catalog,
                                     java.lang.String schema,
                                     java.lang.String table,
                                     java.lang.String columnNamePattern)
                              throws java.sql.SQLException
Accessor for table and column information for a catalog/schema in this datastore.

Parameters:
conn - Connection to use
catalog - The catalog (null if none)
schema - The schema (null if none)
table - The table (null if all)
columnNamePattern - The column name (null if all)
Returns:
ResultSet containing the table/column information
Throws:
java.sql.SQLException - Thrown if an error occurs

getTables

public java.sql.ResultSet getTables(java.sql.Connection conn,
                                    java.lang.String catalog,
                                    java.lang.String schema)
                             throws java.sql.SQLException
Accessor for table information for a catalog/schema in this datastore.

Parameters:
conn - Connection to use
catalog - The catalog (null if none)
schema - The schema (null if none)
Returns:
ResultSet containing the table/column information
Throws:
java.sql.SQLException - Thrown if an error occurs

supportsForeignKeyUpdateAction

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

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

Parameters:
action - The delete action
Returns:
Whether it is supported

supportsDeferredConstraints

public boolean supportsDeferredConstraints()
Whether this datastore supports deferred constraints.

Returns:
whether we support deferred constraints.

includeOrderByColumnsInSelect

public boolean includeOrderByColumnsInSelect()
Whether to include ORDER BY columns in a SELECT.

Returns:
Whether to include ORDER BY in SELECTs

getInsertStatementForNoColumns

public java.lang.String getInsertStatementForNoColumns(Table table)
Method to retutn the INSERT statement to use when inserting into a table that has no columns specified. This is the case when we have a single column in the table and that column is autoincrement/identity (and so is assigned automatically in the datastore).

Parameters:
table - The table
Returns:
The statement for the INSERT

getMaxConstraintNameLength

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

Returns:
Max constraint name length

getMaxColumnNameLength

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

Returns:
Max column name length

isBitReallyBoolean

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

Returns:
Whether it is really a boolean

supportsSettingBlobUsingSetString

public boolean supportsSettingBlobUsingSetString()
Accessor for whether setting a BLOB value allows use of PreparedStatement.setString()

Returns:
Whether setString is allowed.

supportsSettingClobUsingSetString

public boolean supportsSettingClobUsingSetString()
Accessor for whether setting a CLOB value allows use of PreparedStatement.setString()

Returns:
Whether setString is allowed.

getUnlimitedLengthPrecisionValue

public int getUnlimitedLengthPrecisionValue(TypeInfo typeInfo)
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.

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.

supportsDefaultBeforeNullInColumnOptions

public boolean supportsDefaultBeforeNullInColumnOptions()
Whether any DEFAULT tag will be before any NULL/NOT NULL in the column options.

Returns:
Whether to put DEFAULT before NULL

supportsDefaultKeywordInColumnOptions

public boolean supportsDefaultKeywordInColumnOptions()
Whether we support DEFAULT tag in CREATE TABLE statements

Returns:
whether we support the DEFAULT tag in CREATE TABLE

supportsDefaultKeywordWithNotNullInColumnOptions

public boolean supportsDefaultKeywordWithNotNullInColumnOptions()
Whether we support DEFAULT tag together with NOT NULL in CREATE TABLE statements.
 CREATE TABLE X ( MEMORY_SIZE BIGINT DEFAULT 0 NOT NULL )
 
Some databases only support DEFAULT {ConstantExpression | NULL}

Returns:
whether we support the DEFAULT tag together with NOT NULL in CREATE TABLE

supportsNullsKeywordInColumnOptions

public boolean supportsNullsKeywordInColumnOptions()
Whether the database support NULLs in the column options for table creation.

Returns:
whether the database support NULLs in the column options for table creation.

supportsCheckInCreateStatements

public boolean supportsCheckInCreateStatements()
Whether this datastore supports the use of CHECK in CREATE TABLE statements (DDL).

Returns:
whether we can use CHECK in CREATE TABLE.

getAutoIncrementStmt

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

Parameters:
tableName - Name of table (that the autoincrement is for)
columnName - (that the autoincrement is for)
Returns:
The statement for getting the latest auto-increment/identity key

getAutoIncrementKeyword

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

Returns:
The keyword for a column using auto-increment/identity

supportsAutoIncrementKeysNullSpecification

public boolean supportsAutoIncrementKeysNullSpecification()
Whether we support auto-increment/identity keys with nullability specification.

Returns:
whether we support auto-increment keys with nullability spec.

supportsAutoIncrementColumnTypeSpecification

public boolean supportsAutoIncrementColumnTypeSpecification()
Whether we support auto-increment/identity keys with column type specification.

Returns:
whether we support auto-increment keys with column type spec.

supportsUniqueConstraintsInEndCreateStatements

public boolean supportsUniqueConstraintsInEndCreateStatements()
Whether this datastore supports the use of UNIQUE after the column definitions in CREATE TABLE statements (DDL). e.g.
 CREATE TABLE XXX
 (
     COL_A int,
     COL_B char(1),
     PRIMARY KEY (COL_A),
     UNIQUE (COL_B ...)
 )
 

Returns:
whether we can use UNIQUE after the column definitions CREATE TABLE.

getMaxTableNameLength

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

Returns:
Max table name length

getMaxIndexNameLength

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

Returns:
Max index name length

isSQLKeyword

public boolean isSQLKeyword(java.lang.String word)
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.

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

getDropTableStatement

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

 DROP TABLE FOO CASCADE
 

Parameters:
table - The table to drop.
Returns:
The text of the SQL statement.

getAddCandidateKeyStatement

public java.lang.String getAddCandidateKeyStatement(CandidateKey ck)
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)
 

Parameters:
ck - An object describing the candidate key.
Returns:
The text of the SQL statement.

supportsNullsInCandidateKeys

public boolean supportsNullsInCandidateKeys()
Whether we support NULLs in candidate keys.

Returns:
whether we support NULLs in candidate keys.

isValidPrimaryKeyType

public boolean isValidPrimaryKeyType(int datatype)
Method to return whether the specified JDBC type is valid for use in a PrimaryKey.

Parameters:
datatype - The JDBC type.
Returns:
Whether it is valid for use in the PK

getAddColumnStatement

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

Parameters:
table - The table
col - The column
Returns:
The SQL necessary to add the column

createIndexesBeforeForeignKeys

public boolean createIndexesBeforeForeignKeys()
Whether to create indexes before foreign keys.

Returns:
Whether to create indexes before foreign keys

supportsAlterTableDropConstraint

public boolean supportsAlterTableDropConstraint()
Whether this datastore supports ALTER TABLE DROP constraints

Returns:
whether we support ALTER TABLE DROP constraints

supportsAlterTableDropForeignKeyConstraint

public boolean supportsAlterTableDropForeignKeyConstraint()
Whether this datastore supports ALTER TABLE DROP FOREIGN KEY constraints

Returns:
whether we support ALTER TABLE DROP FOREIGN KEY constraints

getCreateIndexStatement

public java.lang.String getCreateIndexStatement(Index idx)
Returns the appropriate SQL to add an index to its table. It should return something like:

 CREATE INDEX FOO_N1 ON FOO (BAR,BAZ)
 CREATE UNIQUE INDEX FOO_U1 ON FOO (BAR,BAZ)
 

Parameters:
idx - An object describing the index.
Returns:
The text of the SQL statement.

getExistingIndexes

public java.sql.ResultSet getExistingIndexes(java.sql.Connection conn,
                                             java.sql.DatabaseMetaData dmd,
                                             java.lang.String catalog,
                                             java.lang.String schema,
                                             java.lang.String table)
                                      throws java.sql.SQLException
Provide the existing indexes in the database for the table

Parameters:
conn - the JDBC connection
dmd - the DatabaseMetaData
catalog - the catalog name
schema - the schema name
table - the table name
Returns:
a ResultSet with the format @see DatabaseMetaData#getIndexInfo(java.lang.String, java.lang.String, java.lang.String, boolean, boolean)
Throws:
java.sql.SQLException

getCreateTableStatement

public java.lang.String getCreateTableStatement(TableImpl table,
                                                Column[] columns,
                                                java.util.Properties props)
Returns the appropriate SQL to create the given table having the given columns. No column constraints or key definitions should be included. It should return something like:

 CREATE TABLE FOO (BAR VARCHAR(30), BAZ INTEGER)
 

Parameters:
table - The table to create.
columns - The columns of the table.
props - Properties for controlling the table creation
Returns:
The text of the SQL statement.

getAddPrimaryKeyStatement

public java.lang.String getAddPrimaryKeyStatement(PrimaryKey pk)
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)
 

Parameters:
pk - An object describing the primary key.
Returns:
The text of the SQL statement.

getAddForeignKeyStatement

public java.lang.String getAddForeignKeyStatement(ForeignKey fk)
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)
 

Parameters:
fk - An object describing the foreign key.
Returns:
The text of the SQL statement.

getDropViewStatement

public java.lang.String getDropViewStatement(ViewImpl view)
Returns the appropriate SQL to drop the given view. It should return something like:

 DROP VIEW FOO
 

Parameters:
view - The view to drop.
Returns:
The text of the SQL statement.

getTypeInfo

public TypeInfo getTypeInfo(int dataType)
                     throws UnsupportedDataTypeException
Returns type information for the database type that best implements the given JDBC type.

Parameters:
dataType - JDBC type number of the data type.
Returns:
type information for the best matching type.
Throws:
UnsupportedDataTypeException - Thrown if the specified datatype is not supported.

isNullEqualsEmptyStrings

public boolean isNullEqualsEmptyStrings()
Some databases, Oracle, treats an empty string (0 length) equals null

Returns:
whether the database treats an empty string as null

getSurrogateForEmptyStrings

public java.lang.String getSurrogateForEmptyStrings()
Some databases, Oracle, treats an empty string (0 length) equals null

Returns:
returns a surrogate to replace the empty string in the database otherwise it would be treated as null

supportsSequences

public boolean supportsSequences()
Whether we support sequences.

Specified by:
supportsSequences in interface DatastoreAdapter
Returns:
whether we support sequences.

requiresColumnDefaultsInitialising

public boolean requiresColumnDefaultsInitialising()
Accessor for whether the column defaults need initialising for this datastore

Returns:
Whether to initialise the column defaults

getTransactionIsolationForSchemaCreation

public int getTransactionIsolationForSchemaCreation()
Accessor for the transaction isolation level to use during schema creation.

Returns:
The transaction isolation level for schema generation process

getCatalogName

public java.lang.String getCatalogName(java.sql.Connection conn)
                                throws java.sql.SQLException
Accessor for the Catalog Name for this datastore.

Parameters:
conn - Connection to the datastore
Returns:
The catalog name
Throws:
java.sql.SQLException - Thrown if error occurs in determining the catalog name.

getSchemaName

public java.lang.String getSchemaName(java.sql.Connection conn)
                               throws java.sql.SQLException
Accessor for the Schema Name for this datastore.

Parameters:
conn - Connection to the datastore
Returns:
The schema name
Throws:
java.sql.SQLException - Thrown if error occurs in determining the schema name.

supportsAnsiJoinSyntax

public boolean supportsAnsiJoinSyntax()
Accessor for whether the RDBMS supports ANSI join syntax.

Returns:
Whether the RDBMS supports ANSI join syntax

getNonAnsiLeftOuterJoinWhereClause

public java.lang.String getNonAnsiLeftOuterJoinWhereClause(java.lang.String col1,
                                                           java.lang.String col2)
Accessor for the WHERE clause to add to provide a LEFT OUTER JOIN using non-ANSI syntax.

Parameters:
col1 - The main datastore column
col2 - The secondary column to join to
Returns:
The Left Outer Join WHERE clause.

getNonAnsiInnerJoinWhereClause

public java.lang.String getNonAnsiInnerJoinWhereClause(java.lang.String col1,
                                                       java.lang.String col2)
Accessor for the WHERE clause to add to provide an INNER JOIN using non-ANSI syntax.

Parameters:
col1 - The main datastore column
col2 - The secondary column to join to
Returns:
The Inner Join WHERE clause.

supportsLockWithSelectForUpdate

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

Returns:
whether we support SELECT ... FOR UPDATE.

getSelectWithLockOption

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

Returns:
The option to specify with "SELECT ... FROM TABLE ... WITH (option)"

getPlaceWithOptionAfterFromClause

public boolean getPlaceWithOptionAfterFromClause()
Determines whether the getSelectWithLockOption() is to be placed right before the FROM clause, or at the end of the statement

Returns:
true if option has to be placed right after the from clause

getPlaceWithOptionWithinJoinClauses

public boolean getPlaceWithOptionWithinJoinClauses()
Determines whether lock option has to be placed within JOIN clauses as well.

Returns:
true if option has to be placed right after the join clause

newTableExpression

public LogicSetExpression newTableExpression(QueryExpression qs,
                                             DatastoreContainerObject table,
                                             DatastoreIdentifier rangeVar)
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.

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

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. When using the UNION statement, keep in mind that, by default, it performs the equivalent of a SELECT DISTINCT on the final result set. In other words, UNION takes the results of two like recordsets, combines them, and then performs a SELECT DISTINCT in order to eliminate any duplicate rows. This process occurs even if there are no duplicate records in the final recordset. If you know that there are duplicate records, and this presents a problem for your application, then by all means use the UNION statement to eliminate the duplicate rows. On the other hand, if you know that there will never be any duplicate rows, or if there are, and this presents no problem to your application, then you should use the UNION ALL statement instead of the UNION statement. The advantage of the UNION ALL is that is does not perform the SELECT DISTINCT function, which saves a lot of unnecessary SQL Server resources from being using.

Returns:
Whether to use UNION ALL instead of UNION

supportsDistinctWithSelectForUpdate

public boolean supportsDistinctWithSelectForUpdate()
Whether this datastore supports using DISTINCT when using SELECT ... FOR UPDATE.

Returns:
whether the datastore supports DISTINCT in same statement as FOR UPDATE

getSelectNewUUIDStmt

public java.lang.String getSelectNewUUIDStmt()
The function to creates a unique value of type uniqueidentifier.

Returns:
The function. e.g. "SELECT NEWID()"

getSequenceNextStmt

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

Parameters:
sequence_name - Name of the sequence
Returns:
The statement for getting the next id for the sequence

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 create statement for this datastore. TODO Change param types to int.

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

iteratorTypeInfo

public java.util.Iterator iteratorTypeInfo()
Iterator for the TypeInfo objects constructed from the method DataBaseMetaData.getTypeInfo

Returns:
an Iterator with org.jpox.store.rdbms.typeinfo.TypeInfo

iteratorReservedWords

public java.util.Iterator iteratorReservedWords()
Iterator for the reserved words constructed from the method DataBaseMetaData.getSQLKeywords + standard SQL reserved words

Returns:
an Iterator with a set of reserved words

supportsPrimaryKeyInCreateStatements

public boolean supportsPrimaryKeyInCreateStatements()
Whether the datastore supports specification of the primary key in CREATE TABLE statements.

Returns:
Whetehr it allows "PRIMARY KEY ..."

supportsStatementGetGeneratedKeys

public boolean supportsStatementGetGeneratedKeys()
Whether the datastore supports Statement.getGeneratedKeys()

Returns:
true if it is supported


Copyright © -2007 . All Rights Reserved.