org.apache.openjpa.jdbc.sql
Class OracleDictionary

java.lang.Object
  extended by org.apache.openjpa.jdbc.sql.DBDictionary
      extended by org.apache.openjpa.jdbc.sql.OracleDictionary
All Implemented Interfaces:
JoinSyntaxes, Configurable, ConnectionDecorator, LoggingConnectionDecorator.SQLWarningHandler

public class OracleDictionary
extends DBDictionary

Dictionary for Oracle.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.openjpa.jdbc.sql.DBDictionary
DBDictionary.SerializedData
 
Field Summary
 String autoAssignSequenceName
          The global sequence name to use for autoassign simulation.
 boolean openjpa3GeneratedKeyNames
          Flag to use OpenJPA 0.3 style naming for auto assign sequence name and trigger name for backwards compatibility.
static String SELECT_HINT
           
 boolean useSetFormOfUseForUnicode
          If true, then OpenJPA will attempt to use the special OraclePreparedStatement.setFormOfUse method to configure statements that it detects are operating on unicode fields.
 boolean useTriggersForAutoAssign
          If true, then simulate auto-assigned values in Oracle by using a trigger that inserts a sequence value into the primary key value when a row is inserted.
static String VENDOR_ORACLE
           
 
Fields inherited from class org.apache.openjpa.jdbc.sql.DBDictionary
allowsAliasInBulkClause, arrayTypeName, autoAssignClause, autoAssignTypeName, batchLimit, bigintTypeName, binaryTypeName, bitLengthFunction, bitTypeName, blobBufferSize, blobTypeName, booleanTypeName, castFunction, catalogSeparator, CENTI, characterColumnSize, charTypeName, clobBufferSize, clobTypeName, closePoolSQL, concatenateDelimiter, concatenateFunction, conf, connected, CONS_NAME_AFTER, CONS_NAME_BEFORE, CONS_NAME_MID, constraintNameMode, createPrimaryKeys, crossJoinClause, currentDateFunction, currentTimeFunction, currentTimestampFunction, datePrecision, dateTypeName, DECI, decimalTypeName, distinctCountColumnSeparator, distinctTypeName, doubleTypeName, driverVendor, dropTableSQL, EMPTY_STRING_LIST, fixedSizeTypeNames, fixedSizeTypeNameSet, floatTypeName, forUpdateClause, getStringVal, inClauseLimit, initializationSQL, innerJoinClause, integerTypeName, javaObjectTypeName, joinSyntax, lastGeneratedKeyQuery, log, longVarbinaryTypeName, longVarcharTypeName, maxAutoAssignNameLength, maxColumnNameLength, maxConstraintNameLength, maxEmbeddedBlobSize, maxEmbeddedClobSize, maxIndexesPerTable, maxIndexNameLength, maxTableNameLength, MICRO, MILLI, NAME_ANY, NAME_SEQUENCE, NAME_TABLE, NANO, nextSequenceQuery, NO_BATCH, nullTypeName, numericTypeName, otherTypeName, outerJoinClause, platform, RANGE_POST_DISTINCT, RANGE_POST_LOCK, RANGE_POST_SELECT, RANGE_PRE_DISTINCT, rangePosition, realTypeName, refTypeName, requiresAliasForSubselect, requiresAutoCommitForMetaData, requiresCastForComparisons, requiresCastForMathFunctions, requiresConditionForCrossJoin, requiresTargetForDelete, reservedWords, reservedWordSet, SCHEMA_CASE_LOWER, SCHEMA_CASE_PRESERVE, SCHEMA_CASE_UPPER, schemaCase, searchStringEscape, SEC, selectWords, selectWordSet, sequenceNameSQL, sequenceSchemaSQL, sequenceSQL, simulateLocking, smallintTypeName, SQL_STATE_CODES, storageLimitationsFatal, storeCharsAsNumbers, storeLargeNumbersAsStrings, stringLengthFunction, structTypeName, substringFunctionName, supportsAlterTableWithAddColumn, supportsAlterTableWithDropColumn, supportsAutoAssign, supportsCascadeDeleteAction, supportsCascadeUpdateAction, supportsComments, supportsCorrelatedSubselect, supportsDefaultDeleteAction, supportsDefaultUpdateAction, supportsDeferredConstraints, supportsForeignKeys, supportsHaving, supportsLockingWithDistinctClause, supportsLockingWithInnerJoin, supportsLockingWithMultipleTables, supportsLockingWithOrderClause, supportsLockingWithOuterJoin, supportsLockingWithSelectRange, supportsModOperator, supportsMultipleNontransactionalResultSets, supportsNullDeleteAction, supportsNullTableForGetColumns, supportsNullTableForGetImportedKeys, supportsNullTableForGetIndexInfo, supportsNullTableForGetPrimaryKeys, supportsNullUpdateAction, supportsQueryTimeout, supportsRestrictDeleteAction, supportsRestrictUpdateAction, supportsSchemaForGetColumns, supportsSchemaForGetTables, supportsSelectEndIndex, supportsSelectForUpdate, supportsSelectStartIndex, supportsSubselect, supportsTimestampNanos, supportsUniqueConstraints, supportsXMLColumn, systemSchemas, systemSchemaSet, systemTables, systemTableSet, tableForUpdateClause, tableTypes, timestampTypeName, timeTypeName, tinyintTypeName, toLowerCaseFunction, toUpperCaseFunction, trimBothFunction, trimLeadingFunction, trimTrailingFunction, typeModifierSet, UNLIMITED, useGetBestRowIdentifierForPrimaryKeys, useGetBytesForBlobs, useGetObjectForBlobs, useGetStringForClobs, useSchemaName, useSetBytesForBlobs, useSetStringForClobs, validationSQL, varbinaryTypeName, varcharTypeName, VENDOR_DATADIRECT, VENDOR_OTHER, xmlTypeName
 
Fields inherited from interface org.apache.openjpa.jdbc.sql.JoinSyntaxes
SYNTAX_DATABASE, SYNTAX_SQL92, SYNTAX_TRADITIONAL
 
Constructor Summary
OracleDictionary()
           
 
Method Summary
 void appendXmlComparison(SQLBuffer buf, String op, FilterValue lhs, FilterValue rhs, boolean lhsxml, boolean rhsxml)
          If this dictionary supports XML type, use this method to append xml predicate.
 boolean canOuterJoin(int syntax, ForeignKey fk)
          Returns if the given foreign key can be eagerly loaded using other joins.
 void connectedConfiguration(Connection conn)
          This method is called when the dictionary first sees any connection.
 void endConfiguration()
          Invoked upon completion of bean property configuration for this object.
 void ensureDriverVendor()
          Ensure that the driver vendor has been set, and if not, set it now.
 String getClobString(ResultSet rs, int column)
          Convert the specified column of the SQL ResultSet to the proper java type.
 Column[] getColumns(DatabaseMetaData meta, String catalog, String schemaName, String tableName, String columnName, Connection conn)
          Reflect on the schema to find columns matching the given table and column patterns.
 String[] getCreateSequenceSQL(Sequence seq)
          Return a series of SQL statements to create the given sequence.
 String[] getCreateTableSQL(Table table)
          Return a series of SQL statements to create the given table, complete with columns.
 Object getGeneratedKey(Column col, Connection conn)
          Return the last generated value for the given column.
protected  String getGeneratedKeyTriggerName(Column col)
          Trigger name for simulating auto-assign values on the given column.
 ForeignKey[] getImportedKeys(DatabaseMetaData meta, String catalog, String schemaName, String tableName, Connection conn)
          Reflect on the schema to return foreign keys imported by the given table pattern.
 Index[] getIndexInfo(DatabaseMetaData meta, String catalog, String schemaName, String tableName, boolean unique, boolean approx, Connection conn)
          Reflect on the schema to find indexes matching the given table pattern.
 Object getObject(ResultSet rs, int column, Map map)
          Convert the specified column of the SQL ResultSet to the proper java type.
protected  String getOpenJPA3GeneratedKeySequenceName(Column col)
          Returns a OpenJPA 3-compatible name for an auto-assign sequence.
protected  String getOpenJPA3GeneratedKeyTriggerName(Column col)
          Returns a OpenJPA 3-compatible name for an auto-assign trigger.
 PrimaryKey[] getPrimaryKeys(DatabaseMetaData meta, String catalog, String schemaName, String tableName, Connection conn)
          Reflect on the schema to find primary keys for the given table pattern.
 String getSelectOperation(JDBCFetchConfiguration fetch)
          Check to see if we have set the SELECT_HINT in the fetch configuraiton, and if so, append the Orache hint after the "SELECT" part of the query.
protected  SQLBuffer getSelects(Select sel, boolean distinctIdentifiers, boolean forUpdate)
          Return the portion of the select statement between the SELECT keyword and the FROM keyword.
protected  String getSequencesSQL(String schemaName, String sequenceName)
          Return the SQL needed to select the list of sequences.
 Timestamp getTimestamp(ResultSet rs, int column, Calendar cal)
          Convert the specified column of the SQL ResultSet to the proper java type.
 void insertBlobForStreamingLoad(Row row, Column col, Object ob)
           
 void insertClobForStreamingLoad(Row row, Column col, Object ob)
           
 boolean isSystemSequence(String name, String schema, boolean targetSchema)
          This method is used to filter system sequences from database metadata.
 void putBytes(Object blob, byte[] data)
          Invoke Oracle's putBytes method on the given BLOB object.
 void putChars(Object clob, char[] data)
          Invoke Oracle's putChars method on the given CLOB object.
 void putString(Object clob, String data)
          Invoke Oracle's putString method on the given CLOB object.
 void setNull(PreparedStatement stmnt, int idx, int colType, Column col)
          Set the given value as a parameters to the statement.
 void setString(PreparedStatement stmnt, int idx, String val, Column col)
          Set the given value as a parameter to the statement.
 boolean supportsLocking(Select sel)
          Returns true if a "FOR UPDATE" clause can be used for the specified Select object.
 SQLBuffer toNativeJoin(Join join)
          Use the given join instance to create SQL joining its tables in the database's native syntax.
 SQLBuffer toSelect(SQLBuffer select, JDBCFetchConfiguration fetch, SQLBuffer tables, SQLBuffer where, SQLBuffer group, SQLBuffer having, SQLBuffer order, boolean distinct, boolean forUpdate, long start, long end, Select sel)
          Combine the given components into a SELECT statement.
 
Methods inherited from class org.apache.openjpa.jdbc.sql.DBDictionary
addCastAsType, appendCast, appendLength, appendNumericCast, appendSelect, appendSelectRange, appendSize, appendUpdates, assertSupport, calculateValue, closeDataSource, comment, comparison, convertSchemaCase, copy, copy, createIndexIfNecessary, decorate, deleteStream, executeQuery, getAddColumnSQL, getAddForeignKeySQL, getAddPrimaryKeySQL, getArray, getAsciiStream, getBatchLimit, getBigDecimal, getBigInteger, getBinaryStream, getBlob, getBlobObject, getBoolean, getByte, getBytes, getCalendar, getCastFunction, getCatalogNameForMetadata, getChar, getCharacterStream, getClob, getColumnNameForMetadata, getCreateIndexSQL, getDate, getDate, getDeclareColumnSQL, getDeleteTableContentsSQL, getDeleteTargets, getDouble, getDropColumnSQL, getDropForeignKeySQL, getDropIndexSQL, getDropPrimaryKeySQL, getDropSequenceSQL, getDropTableSQL, getFloat, getForeignKeyConstraintSQL, getForUpdateClause, getFrom, getFromSelect, getFullName, getFullName, getFullName, getGeneratedKeySequenceName, getInt, getJDBCType, getKey, getLOBStream, getLocale, getLong, getNumber, getPlaceholderValueString, getPreferredType, getPrimaryKeyConstraintSQL, getPrimaryKeysFromBestRowIdentifier, getPrimaryKeysFromGetPrimaryKeys, getRef, getSchemaCase, getSchemaNameForMetadata, getSequence, getSequences, getShort, getSQLStates, getString, getTableNameForMetadata, getTables, getTime, getTypeName, getTypeName, getUniqueConstraintSQL, getValidColumnName, getValidColumnName, getValidForeignKeyName, getValidIndexName, getValidPrimaryKeyName, getValidSequenceName, getValidTableName, getValidUniqueName, getVersionColumn, getWhere, handleWarning, indexOf, insertBlobForStreamingLoad, insertSize, isSelect, isSystemIndex, isSystemTable, makeNameValid, makeNameValid, mathFunction, newColumn, newForeignKey, newIndex, newPrimaryKey, newSequence, newStoreException, newTable, prepareStatement, refSchemaComponents, serialize, setArray, setAsciiStream, setBatchLimit, setBigDecimal, setBigInteger, setBinaryStream, setBlob, setBlobObject, setBoolean, setByte, setBytes, setCalendar, setChar, setCharacterStream, setClob, setClobString, setConfiguration, setDate, setDate, setDouble, setFloat, setInt, setJoinSyntax, setLocale, setLong, setNumber, setObject, setRef, setShort, setTime, setTimestamp, setTyped, setUnknown, shorten, startConfiguration, storageWarning, substring, supportsDeferredForeignKeyConstraints, supportsDeferredUniqueConstraints, supportsDeleteAction, supportsRandomAccessResultSet, supportsUpdateAction, toBulkOperation, toDelete, toOperation, toOperation, toSelect, toSelect, toSelect, toSelect, toSelectCount, toSQL92Join, toTraditionalJoin, toUpdate, updateBlob, updateClob, validateBatchProcess, validateDBSpecificBatchProcess
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SELECT_HINT

public static final String SELECT_HINT
See Also:
Constant Field Values

VENDOR_ORACLE

public static final String VENDOR_ORACLE
See Also:
Constant Field Values

useTriggersForAutoAssign

public boolean useTriggersForAutoAssign
If true, then simulate auto-assigned values in Oracle by using a trigger that inserts a sequence value into the primary key value when a row is inserted.


autoAssignSequenceName

public String autoAssignSequenceName
The global sequence name to use for autoassign simulation.


openjpa3GeneratedKeyNames

public boolean openjpa3GeneratedKeyNames
Flag to use OpenJPA 0.3 style naming for auto assign sequence name and trigger name for backwards compatibility.


useSetFormOfUseForUnicode

public boolean useSetFormOfUseForUnicode
If true, then OpenJPA will attempt to use the special OraclePreparedStatement.setFormOfUse method to configure statements that it detects are operating on unicode fields.

Constructor Detail

OracleDictionary

public OracleDictionary()
Method Detail

endConfiguration

public void endConfiguration()
Description copied from interface: Configurable
Invoked upon completion of bean property configuration for this object.

Specified by:
endConfiguration in interface Configurable
Overrides:
endConfiguration in class DBDictionary

connectedConfiguration

public void connectedConfiguration(Connection conn)
                            throws SQLException
Description copied from class: DBDictionary
This method is called when the dictionary first sees any connection. It is used to initialize dictionary metadata if needed. If you override this method, be sure to call super.connectedConfiguration.

Overrides:
connectedConfiguration in class DBDictionary
Throws:
SQLException

ensureDriverVendor

public void ensureDriverVendor()
Ensure that the driver vendor has been set, and if not, set it now.


supportsLocking

public boolean supportsLocking(Select sel)
Description copied from class: DBDictionary
Returns true if a "FOR UPDATE" clause can be used for the specified Select object.

Overrides:
supportsLocking in class DBDictionary

getSelects

protected SQLBuffer getSelects(Select sel,
                               boolean distinctIdentifiers,
                               boolean forUpdate)
Description copied from class: DBDictionary
Return the portion of the select statement between the SELECT keyword and the FROM keyword.

Overrides:
getSelects in class DBDictionary

canOuterJoin

public boolean canOuterJoin(int syntax,
                            ForeignKey fk)
Description copied from class: DBDictionary
Returns if the given foreign key can be eagerly loaded using other joins.

Overrides:
canOuterJoin in class DBDictionary

toNativeJoin

public SQLBuffer toNativeJoin(Join join)
Description copied from class: DBDictionary
Use the given join instance to create SQL joining its tables in the database's native syntax. Throws an exception by default.

Overrides:
toNativeJoin in class DBDictionary

toSelect

public SQLBuffer toSelect(SQLBuffer select,
                          JDBCFetchConfiguration fetch,
                          SQLBuffer tables,
                          SQLBuffer where,
                          SQLBuffer group,
                          SQLBuffer having,
                          SQLBuffer order,
                          boolean distinct,
                          boolean forUpdate,
                          long start,
                          long end,
                          Select sel)
Description copied from class: DBDictionary
Combine the given components into a SELECT statement.

Overrides:
toSelect in class DBDictionary

getSelectOperation

public String getSelectOperation(JDBCFetchConfiguration fetch)
Check to see if we have set the SELECT_HINT in the fetch configuraiton, and if so, append the Orache hint after the "SELECT" part of the query.

Overrides:
getSelectOperation in class DBDictionary

setString

public void setString(PreparedStatement stmnt,
                      int idx,
                      String val,
                      Column col)
               throws SQLException
Description copied from class: DBDictionary
Set the given value as a parameter to the statement.

Overrides:
setString in class DBDictionary
Throws:
SQLException

setNull

public void setNull(PreparedStatement stmnt,
                    int idx,
                    int colType,
                    Column col)
             throws SQLException
Description copied from class: DBDictionary
Set the given value as a parameters to the statement. The column type will come from Types.

Overrides:
setNull in class DBDictionary
Throws:
SQLException

getClobString

public String getClobString(ResultSet rs,
                            int column)
                     throws SQLException
Description copied from class: DBDictionary
Convert the specified column of the SQL ResultSet to the proper java type.

Overrides:
getClobString in class DBDictionary
Throws:
SQLException

getTimestamp

public Timestamp getTimestamp(ResultSet rs,
                              int column,
                              Calendar cal)
                       throws SQLException
Description copied from class: DBDictionary
Convert the specified column of the SQL ResultSet to the proper java type.

Overrides:
getTimestamp in class DBDictionary
Throws:
SQLException

getObject

public Object getObject(ResultSet rs,
                        int column,
                        Map map)
                 throws SQLException
Description copied from class: DBDictionary
Convert the specified column of the SQL ResultSet to the proper java type.

Overrides:
getObject in class DBDictionary
Throws:
SQLException

getColumns

public Column[] getColumns(DatabaseMetaData meta,
                           String catalog,
                           String schemaName,
                           String tableName,
                           String columnName,
                           Connection conn)
                    throws SQLException
Description copied from class: DBDictionary
Reflect on the schema to find columns matching the given table and column patterns.

Overrides:
getColumns in class DBDictionary
Throws:
SQLException

getPrimaryKeys

public PrimaryKey[] getPrimaryKeys(DatabaseMetaData meta,
                                   String catalog,
                                   String schemaName,
                                   String tableName,
                                   Connection conn)
                            throws SQLException
Description copied from class: DBDictionary
Reflect on the schema to find primary keys for the given table pattern.

Overrides:
getPrimaryKeys in class DBDictionary
Throws:
SQLException

getIndexInfo

public Index[] getIndexInfo(DatabaseMetaData meta,
                            String catalog,
                            String schemaName,
                            String tableName,
                            boolean unique,
                            boolean approx,
                            Connection conn)
                     throws SQLException
Description copied from class: DBDictionary
Reflect on the schema to find indexes matching the given table pattern.

Overrides:
getIndexInfo in class DBDictionary
Throws:
SQLException

getImportedKeys

public ForeignKey[] getImportedKeys(DatabaseMetaData meta,
                                    String catalog,
                                    String schemaName,
                                    String tableName,
                                    Connection conn)
                             throws SQLException
Description copied from class: DBDictionary
Reflect on the schema to return foreign keys imported by the given table pattern.

Overrides:
getImportedKeys in class DBDictionary
Throws:
SQLException

getCreateTableSQL

public String[] getCreateTableSQL(Table table)
Description copied from class: DBDictionary
Return a series of SQL statements to create the given table, complete with columns. Indexes and constraints will be created separately.

Overrides:
getCreateTableSQL in class DBDictionary

getCreateSequenceSQL

public String[] getCreateSequenceSQL(Sequence seq)
Description copied from class: DBDictionary
Return a series of SQL statements to create the given sequence. Returns CREATE SEQUENCE <sequence name>[ START WITH <start>] [ INCREMENT BY <increment>] by default.

Overrides:
getCreateSequenceSQL in class DBDictionary

getSequencesSQL

protected String getSequencesSQL(String schemaName,
                                 String sequenceName)
Description copied from class: DBDictionary
Return the SQL needed to select the list of sequences.

Overrides:
getSequencesSQL in class DBDictionary

isSystemSequence

public boolean isSystemSequence(String name,
                                String schema,
                                boolean targetSchema)
Description copied from class: DBDictionary
This method is used to filter system sequences from database metadata. Return true if the given sequence represents a system sequence that should not appear in the schema definition. Returns true if system schema by default.

Overrides:
isSystemSequence in class DBDictionary
Parameters:
name - the table name
schema - the table schema; may be null
targetSchema - if true, then the given schema was listed by the user as one of his schemas

getGeneratedKey

public Object getGeneratedKey(Column col,
                              Connection conn)
                       throws SQLException
Description copied from class: DBDictionary
Return the last generated value for the given column. Throws an exception by default if DBDictionary.lastGeneratedKeyQuery is null.

Overrides:
getGeneratedKey in class DBDictionary
Throws:
SQLException

getGeneratedKeyTriggerName

protected String getGeneratedKeyTriggerName(Column col)
Trigger name for simulating auto-assign values on the given column.


getOpenJPA3GeneratedKeySequenceName

protected String getOpenJPA3GeneratedKeySequenceName(Column col)
Returns a OpenJPA 3-compatible name for an auto-assign sequence.


getOpenJPA3GeneratedKeyTriggerName

protected String getOpenJPA3GeneratedKeyTriggerName(Column col)
Returns a OpenJPA 3-compatible name for an auto-assign trigger.


putBytes

public void putBytes(Object blob,
                     byte[] data)
              throws SQLException
Invoke Oracle's putBytes method on the given BLOB object. Uses reflection in case the blob is wrapped in another vendor-specific class; for example Weblogic wraps oracle thin driver lobs in its own interfaces with the same methods.

Overrides:
putBytes in class DBDictionary
Throws:
SQLException

putString

public void putString(Object clob,
                      String data)
               throws SQLException
Invoke Oracle's putString method on the given CLOB object. Uses reflection in case the clob is wrapped in another vendor-specific class; for example Weblogic wraps oracle thin driver lobs in its own interfaces with the same methods.

Overrides:
putString in class DBDictionary
Throws:
SQLException

putChars

public void putChars(Object clob,
                     char[] data)
              throws SQLException
Invoke Oracle's putChars method on the given CLOB object. Uses reflection in case the clob is wrapped in another vendor-specific class; for example Weblogic wraps oracle thin driver lobs in its own interfaces with the same methods.

Overrides:
putChars in class DBDictionary
Throws:
SQLException

appendXmlComparison

public void appendXmlComparison(SQLBuffer buf,
                                String op,
                                FilterValue lhs,
                                FilterValue rhs,
                                boolean lhsxml,
                                boolean rhsxml)
If this dictionary supports XML type, use this method to append xml predicate.

Overrides:
appendXmlComparison in class DBDictionary
Parameters:
buf - the SQL buffer to write the comparison
op - the comparison operation to perform
lhs - the left hand side of the comparison
rhs - the right hand side of the comparison

insertBlobForStreamingLoad

public void insertBlobForStreamingLoad(Row row,
                                       Column col,
                                       Object ob)
                                throws SQLException
Throws:
SQLException

insertClobForStreamingLoad

public void insertClobForStreamingLoad(Row row,
                                       Column col,
                                       Object ob)
                                throws SQLException
Overrides:
insertClobForStreamingLoad in class DBDictionary
Throws:
SQLException


Copyright © 2006-2008 Apache Software Foundation. All Rights Reserved.