org.datanucleus.store.rdbms.adapter
Class OracleAdapter

java.lang.Object
  extended by org.datanucleus.store.rdbms.adapter.DatabaseAdapter
      extended by org.datanucleus.store.rdbms.adapter.OracleAdapter
All Implemented Interfaces:
org.datanucleus.store.mapped.DatastoreAdapter, RDBMSAdapter

public class OracleAdapter
extends DatabaseAdapter

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

See Also:
DatabaseAdapter

Field Summary
static String OJDBC_DRIVER_NAME
          What the official Oracle JDBC driver uses to identify itself.
static String ORACLE_10_RESERVED_WORDS
          A string containing the list of Oracle keywords This list is normally obtained dynamically from the driver using DatabaseMetaData.getSQLKeywords() Based on database Oracle10g
static String ORACLE_8_RESERVED_WORDS
          A string containing the list of Oracle keywords This list is normally obtained dynamically from the driver using DatabaseMetaData.getSQLKeywords() Based on database Oracle8
static String ORACLE_9_RESERVED_WORDS
          A string containing the list of Oracle keywords This list is normally obtained dynamically from the driver using DatabaseMetaData.getSQLKeywords() Based on database Oracle9i
 
Fields inherited from class org.datanucleus.store.rdbms.adapter.DatabaseAdapter
catalogSeparator, datastoreMajorVersion, datastoreMinorVersion, datastoreProductName, datastoreProductVersion, datastoreRevisionVersion, driverMajorVersion, driverMinorVersion, driverName, driverVersion, identifierQuoteString, LOCALISER, LOCALISER_BASE, maxColumnNameLength, maxConstraintNameLength, maxIndexNameLength, maxTableNameLength, properties, reservedKeywords, supportedOptions
 
Fields inherited from interface org.datanucleus.store.rdbms.adapter.RDBMSAdapter
ACCESS_PARENTQUERY_IN_SUBQUERY_JOINED, ALTER_TABLE_DROP_CONSTRAINT_SYNTAX, ALTER_TABLE_DROP_FOREIGN_KEY_CONSTRAINT, ANSI_CROSSJOIN_SYNTAX, ANSI_JOIN_SYNTAX, AUTO_INCREMENT_COLUMN_TYPE_SPECIFICATION, AUTO_INCREMENT_KEYS_NULL_SPECIFICATION, AUTO_INCREMENT_PK_IN_CREATE_TABLE_COLUMN_DEF, BLOB_SET_USING_SETSTRING, CHAR_COLUMNS_PADDED_WITH_SPACES, CHECK_IN_CREATE_STATEMENTS, CHECK_IN_END_CREATE_STATEMENTS, CLOB_SET_USING_SETSTRING, CREATE_INDEXES_BEFORE_FOREIGN_KEYS, CROSSJOIN_ASINNER11_SYNTAX, DATETIME_STORES_MILLISECS, DEFAULT_BEFORE_NULL_IN_COLUMN_OPTIONS, DEFAULT_KEYWORD_IN_COLUMN_OPTIONS, DEFAULT_KEYWORD_WITH_NOT_NULL_IN_COLUMN_OPTIONS, DEFERRED_CONSTRAINTS, DISTINCT_WITH_SELECT_FOR_UPDATE, EXISTS_SYNTAX, FK_DELETE_ACTION_CASCADE, FK_DELETE_ACTION_DEFAULT, FK_DELETE_ACTION_NULL, FK_DELETE_ACTION_RESTRICT, FK_IN_END_CREATE_STATEMENTS, FK_UPDATE_ACTION_CASCADE, FK_UPDATE_ACTION_DEFAULT, FK_UPDATE_ACTION_NULL, FK_UPDATE_ACTION_RESTRICT, GET_GENERATED_KEYS_STATEMENT, INCLUDE_ORDERBY_COLS_IN_SELECT, LOCK_OPTION_PLACED_AFTER_FROM, LOCK_OPTION_PLACED_WITHIN_JOIN, LOCK_WITH_SELECT_FOR_UPDATE, NULL_EQUALS_EMPTY_STRING, NULLS_IN_CANDIDATE_KEYS, NULLS_KEYWORD_IN_COLUMN_OPTIONS, ORDERBY_USING_SELECT_COLUMN_INDEX, PERSIST_OF_UNASSIGNED_CHAR, PRIMARYKEY_IN_CREATE_STATEMENTS, STATEMENT_BATCHING, STORED_PROCEDURES, TX_ISOLATION_NONE, TX_ISOLATION_READ_COMMITTED, TX_ISOLATION_READ_UNCOMMITTED, TX_ISOLATION_REPEATABLE_READ, TX_ISOLATION_SERIALIZABLE, UNION_SYNTAX, UNIQUE_IN_END_CREATE_STATEMENTS, UPDATE_MULTITABLE, USE_UNION_ALL, VIEWS
 
Fields inherited from interface org.datanucleus.store.mapped.DatastoreAdapter
ANALYSIS_METHODS, BIT_IS_REALLY_BOOLEAN, BOOLEAN_COMPARISON, CATALOGS_IN_TABLE_DEFINITIONS, ESCAPE_EXPRESSION_IN_LIKE_PREDICATE, IDENTIFIERS_LOWERCASE, IDENTIFIERS_LOWERCASE_QUOTED, IDENTIFIERS_MIXEDCASE, IDENTIFIERS_MIXEDCASE_QUOTED, IDENTIFIERS_MIXEDCASE_QUOTED_SENSITIVE, IDENTIFIERS_MIXEDCASE_SENSITIVE, IDENTIFIERS_UPPERCASE, IDENTIFIERS_UPPERCASE_QUOTED, IDENTITY_COLUMNS, PROJECTION_IN_TABLE_REFERENCE_JOINS, SCHEMAS_IN_TABLE_DEFINITIONS, SEQUENCES
 
Constructor Summary
OracleAdapter(DatabaseMetaData metadata)
          Constructs an Oracle adapter based on the given JDBC metadata.
 
Method Summary
 String getCatalogName(Connection conn)
          Accessor for the Catalog Name for this datastore.
 ResultSet getColumns(Connection conn, String catalog, String schema, String table, String columnNamePattern)
          Accessor for table and column information for a catalog/schema in this datastore.
 String getDatastoreDateStatement()
          Accessor for a statement that will return the statement to use to get the datastore date.
 String getDropTableStatement(org.datanucleus.store.mapped.DatastoreContainerObject table)
          Method to return the drop table statement for Oracle.
 ResultSet getExistingIndexes(Connection conn, String catalog, String schema, String table)
          Provide the existing indexes in the database for the table.
 org.datanucleus.store.mapped.mapping.MappingManager getMappingManager(org.datanucleus.store.mapped.MappedStoreManager storeMgr)
          Accessor for a MappingManager suitable for use with this datastore adapter.
 String getOrderString(org.datanucleus.store.StoreManager storeMgr, String orderString, SQLExpression sqlExpr)
          Convenience method to allow adaption of an ordering string before applying it.
 String getRangeByRowNumberColumn2()
          Method to return the column name to use when handling ranges via a rownumber on the select using the second method (Oracle).
 String getSchemaName(Connection conn)
          Accessor for the Schema Name for this datastore.
 String getSequenceCreateStmt(String sequence_name, Integer min, Integer max, Integer start, Integer increment, Integer cache_size)
          Accessor for the sequence statement to create the sequence.
 String getSequenceNextStmt(String sequence_name)
          Accessor for the statement for getting the next id from the sequence for this datastore.
 String getSurrogateForEmptyStrings()
          Some databases, Oracle, treats an empty string (0 length) equals null
 int getTransactionIsolationForSchemaCreation()
          Accessor for the transaction isolation level to use during schema creation.
 String getVendorID()
          Accessor for the vendor id
 void initialiseTypes(org.datanucleus.store.schema.StoreSchemaHandler handler, org.datanucleus.store.connection.ManagedConnection mconn)
          Initialise the types for this datastore.
 boolean isStatementTimeout(SQLException sqle)
          return whether this exception represents a timed out statement.
 RDBMSColumnInfo newRDBMSColumnInfo(ResultSet rs)
          Method to create a column info for the current row.
 SQLTypeInfo newSQLTypeInfo(ResultSet rs)
          Create a new SQL type info from the current row of the passed ResultSet.
 boolean validToSelectMappingInStatement(SQLStatement stmt, org.datanucleus.store.mapped.mapping.JavaTypeMapping m)
          Method to return if it is valid to select the specified mapping for the specified statement for this datastore adapter.
 
Methods inherited from class org.datanucleus.store.rdbms.adapter.DatabaseAdapter
addSQLTypeForJDBCType, getAdapterTime, getAddCandidateKeyStatement, getAddColumnStatement, getAddForeignKeyStatement, getAddPrimaryKeyStatement, getAutoIncrementKeyword, getAutoIncrementStmt, getCatalogSeparator, getCheckConstraintForValues, getContinuationString, getCreateIndexStatement, getCreateTableStatement, getDatastoreDriverName, getDatastoreDriverVersion, getDatastoreIdentifierMaxLength, getDatastoreProductName, getDatastoreProductVersion, getDeleteTableStatement, getDriverMajorVersion, getDriverMinorVersion, getDropViewStatement, getEscapeCharacter, getEscapePatternExpression, getIdentifierQuoteString, getInsertStatementForNoColumns, getMaxForeignKeys, getMaxIndexes, getMiliseconds, getNewUUIDFunction, getNumericConversionFunction, getOperatorConcat, getPatternExpressionAnyCharacter, getPatternExpressionZeroMoreCharacters, getRangeByLimitEndOfStatementClause, getRangeByRowNumberColumn, getRequiredTransactionIsolationLevel, getSelectForUpdateText, getSelectNewUUIDStmt, getSelectWithLockOption, getSQLTypeInfoForJdbcType, getSupportedOptions, getTime, getUnlimitedLengthPrecisionValue, getValueForProperty, initialiseDatastore, isIdentityFieldDataType, isKeyword, isReservedKeyword, isStatementCancel, isValidPrimaryKeyType, iteratorReservedWords, newFKInfo, parseKeywordList, removeUnsupportedMappings, setProperties, supportsOption, supportsQueryFetchSize, supportsTransactionIsolation, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

OJDBC_DRIVER_NAME

public static final String OJDBC_DRIVER_NAME
What the official Oracle JDBC driver uses to identify itself.

See Also:
Constant Field Values

ORACLE_8_RESERVED_WORDS

public static final String ORACLE_8_RESERVED_WORDS
A string containing the list of Oracle keywords This list is normally obtained dynamically from the driver using DatabaseMetaData.getSQLKeywords() Based on database Oracle8

See Also:
Constant Field Values

ORACLE_9_RESERVED_WORDS

public static final String ORACLE_9_RESERVED_WORDS
A string containing the list of Oracle keywords This list is normally obtained dynamically from the driver using DatabaseMetaData.getSQLKeywords() Based on database Oracle9i

See Also:
Constant Field Values

ORACLE_10_RESERVED_WORDS

public static final String ORACLE_10_RESERVED_WORDS
A string containing the list of Oracle keywords This list is normally obtained dynamically from the driver using DatabaseMetaData.getSQLKeywords() Based on database Oracle10g

See Also:
Constant Field Values
Constructor Detail

OracleAdapter

public OracleAdapter(DatabaseMetaData metadata)
Constructs an Oracle adapter based on the given JDBC metadata.

Parameters:
metadata - the database metadata.
Method Detail

initialiseTypes

public void initialiseTypes(org.datanucleus.store.schema.StoreSchemaHandler handler,
                            org.datanucleus.store.connection.ManagedConnection mconn)
Initialise the types for this datastore.

Specified by:
initialiseTypes in interface org.datanucleus.store.mapped.DatastoreAdapter
Overrides:
initialiseTypes in class DatabaseAdapter
Parameters:
handler - SchemaHandler that we initialise the types for
mconn - Managed connection to use

newSQLTypeInfo

public SQLTypeInfo newSQLTypeInfo(ResultSet rs)
Description copied from interface: RDBMSAdapter
Create a new SQL type info from the current row of the passed ResultSet. Allows an adapter to override particular types where the JDBC driver is known to be buggy.

Specified by:
newSQLTypeInfo in interface RDBMSAdapter
Overrides:
newSQLTypeInfo in class DatabaseAdapter
Parameters:
rs - ResultSet
Returns:
The SQL type info

getMappingManager

public org.datanucleus.store.mapped.mapping.MappingManager getMappingManager(org.datanucleus.store.mapped.MappedStoreManager storeMgr)
Accessor for a MappingManager suitable for use with this datastore adapter.

Specified by:
getMappingManager in interface org.datanucleus.store.mapped.DatastoreAdapter
Overrides:
getMappingManager in class DatabaseAdapter
Parameters:
storeMgr - The StoreManager
Returns:
the MappingManager

getVendorID

public String getVendorID()
Accessor for the vendor id

Specified by:
getVendorID in interface org.datanucleus.store.mapped.DatastoreAdapter
Overrides:
getVendorID in class DatabaseAdapter
Returns:
The Oracle vendor id

getSurrogateForEmptyStrings

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

Specified by:
getSurrogateForEmptyStrings in interface RDBMSAdapter
Overrides:
getSurrogateForEmptyStrings in class DatabaseAdapter
Returns:
returns a surrogate to replace the empty string in the database otherwise it would be treated as null

getCatalogName

public String getCatalogName(Connection conn)
                      throws SQLException
Description copied from class: DatabaseAdapter
Accessor for the Catalog Name for this datastore.

Specified by:
getCatalogName in interface RDBMSAdapter
Overrides:
getCatalogName in class DatabaseAdapter
Parameters:
conn - Connection to the datastore
Returns:
null, because oracle does not have catalogs
Throws:
SQLException - Thrown if error occurs in determining the catalog name.

getSchemaName

public String getSchemaName(Connection conn)
                     throws 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:
SQLException - Thrown if error occurs in determining the schema name.

getExistingIndexes

public ResultSet getExistingIndexes(Connection conn,
                                    String catalog,
                                    String schema,
                                    String table)
                             throws SQLException
Provide the existing indexes in the database for the table. This is implemented if and only if the datastore has its own way of getting indexes. In this implementation we provide an alternate method for Oracle JDBC driver < 10.2.0.1.0 only. All other versions of Oracle will use the default. The schemaName MUST BE PROVIDED.

Specified by:
getExistingIndexes in interface RDBMSAdapter
Overrides:
getExistingIndexes in class DatabaseAdapter
Parameters:
conn - the JDBC connection
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:
SQLException

getDropTableStatement

public String getDropTableStatement(org.datanucleus.store.mapped.DatastoreContainerObject table)
Method to return the drop table statement for Oracle.

Specified by:
getDropTableStatement in interface RDBMSAdapter
Overrides:
getDropTableStatement in class DatabaseAdapter
Parameters:
table - The table
Returns:
The statement text

getSequenceCreateStmt

public String getSequenceCreateStmt(String sequence_name,
                                    Integer min,
                                    Integer max,
                                    Integer start,
                                    Integer increment,
                                    Integer 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 String getSequenceNextStmt(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

newRDBMSColumnInfo

public RDBMSColumnInfo newRDBMSColumnInfo(ResultSet rs)
Method to create a column info for the current row. Overrides the dataType to cater for Oracle particularities.

Specified by:
newRDBMSColumnInfo in interface RDBMSAdapter
Overrides:
newRDBMSColumnInfo in class DatabaseAdapter
Parameters:
rs - ResultSet from DatabaseMetaData.getColumns()
Returns:
column info

getTransactionIsolationForSchemaCreation

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

Specified by:
getTransactionIsolationForSchemaCreation in interface RDBMSAdapter
Overrides:
getTransactionIsolationForSchemaCreation in class DatabaseAdapter
Returns:
The transaction isolation level for schema generation process

getColumns

public ResultSet getColumns(Connection conn,
                            String catalog,
                            String schema,
                            String table,
                            String columnNamePattern)
                     throws SQLException
Accessor for table and column information for a catalog/schema in this datastore. An override for the DatabaseMetaData.getColumns() method call as referenced in superclass. The default Oracle-provided getColumns() method is VERY slow for large schemas, particularly due to REMARKS and COLUMN_DEF (column defaults) columns (outer-joins in data dictionary views) Note: This method DOES NOT return default column value (meta-data ResultSet column COLUMN_DEF) as this column causes MAJOR slowdown in meta-data retrieval performance.

Specified by:
getColumns in interface RDBMSAdapter
Overrides:
getColumns in class DatabaseAdapter
Parameters:
conn - Connection to use
catalog - The catalog (null if none)
schema - The schema (null if none)
table - The table (null if all)
columnNamePattern - Col name(s) (null if all) NOT USED
Returns:
ResultSet containing the table/column information
Throws:
SQLException - Thrown if an error occurs

getDatastoreDateStatement

public String getDatastoreDateStatement()
Accessor for a statement that will return the statement to use to get the datastore date.

Specified by:
getDatastoreDateStatement in interface RDBMSAdapter
Overrides:
getDatastoreDateStatement in class DatabaseAdapter
Returns:
SQL statement to get the datastore date

getOrderString

public String getOrderString(org.datanucleus.store.StoreManager storeMgr,
                             String orderString,
                             SQLExpression sqlExpr)
Convenience method to allow adaption of an ordering string before applying it. This is useful where the datastore accepts some conversion adapter around the ordering column for example.

Specified by:
getOrderString in interface RDBMSAdapter
Overrides:
getOrderString in class DatabaseAdapter
Parameters:
storeMgr - StoreManager
orderString - The basic ordering string
sqlExpr - The sql expression being represented here
Returns:
The adapted ordering string

isStatementTimeout

public boolean isStatementTimeout(SQLException sqle)
Description copied from class: DatabaseAdapter
return whether this exception represents a timed out statement.

Specified by:
isStatementTimeout in interface RDBMSAdapter
Overrides:
isStatementTimeout in class DatabaseAdapter
Parameters:
sqle - the exception
Returns:
whether it is a timeout

validToSelectMappingInStatement

public boolean validToSelectMappingInStatement(SQLStatement stmt,
                                               org.datanucleus.store.mapped.mapping.JavaTypeMapping m)
Method to return if it is valid to select the specified mapping for the specified statement for this datastore adapter. Sometimes, dependent on the type of the column(s), and what other components are present in the statement, it may be invalid to select the mapping. This implementation returns true, so override in database-specific subclass as required.

Specified by:
validToSelectMappingInStatement in interface RDBMSAdapter
Overrides:
validToSelectMappingInStatement in class DatabaseAdapter
Parameters:
stmt - The statement
m - The mapping that we want to select
Returns:
Whether it is valid

getRangeByRowNumberColumn2

public String getRangeByRowNumberColumn2()
Description copied from class: DatabaseAdapter
Method to return the column name to use when handling ranges via a rownumber on the select using the second method (Oracle). Defaults to an empty string (not supported).

Specified by:
getRangeByRowNumberColumn2 in interface RDBMSAdapter
Overrides:
getRangeByRowNumberColumn2 in class DatabaseAdapter
Returns:
The row number column.


Copyright © 2012. All Rights Reserved.