EclipseLink 1.0_1.0M2 API Reference - Incubation

org.eclipse.persistence.platform.database.oracle
Class OraclePlatform

java.lang.Object
  extended by org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
      extended by org.eclipse.persistence.platform.database.DatabasePlatform
          extended by org.eclipse.persistence.platform.database.oracle.OraclePlatform

public class OraclePlatform
extends DatabasePlatform

Purpose: Provides Oracle specific behavior.

Responsibilities:

Since:
TOPLink/Java 1.0

Field Summary
protected  boolean supportsIdentity
          Advanced attribute indicating whether identity is supported, see comment to setSupportsIdentity method.
protected  boolean useRownumFiltering
          Oracle's Rownum can be used to limit results and for pagination, using the query's maxRows and FirstResult settings
 
Constructor Summary
OraclePlatform()
           
 
Method Summary
 boolean allowsSizeInProcedureArguments()
           
protected  void appendByteArray(byte[] bytes, java.io.Writer writer)
          INTERNAL: If using native SQL then print a byte[] literally as a hex string otherwise use ODBC format as provided in DatabasePlatform.
protected  void appendCalendar(java.util.Calendar calendar, java.io.Writer writer)
          INTERNAL: Appends an Oracle specific Timestamp, if usesNativeSQL is true otherwise use the ODBC format.
protected  void appendDate(java.sql.Date date, java.io.Writer writer)
          INTERNAL: Appends an Oracle specific date if usesNativeSQL is true otherwise use the ODBC format.
protected  void appendTime(java.sql.Time time, java.io.Writer writer)
          INTERNAL: Appends an Oracle specific time if usesNativeSQL is true otherwise use the ODBC format.
protected  void appendTimestamp(java.sql.Timestamp timestamp, java.io.Writer writer)
          INTERNAL: Appends an Oracle specific Timestamp, if usesNativeSQL is true otherwise use the ODBC format.
 ExpressionOperator atan2Operator()
          INTERNAL: Build operator.
 DatabaseCall buildCallWithReturning(SQLCall sqlCall, java.util.Vector returnFields)
          INTERNAL: Returns null unless the platform supports call with returning
protected  java.util.Hashtable buildFieldTypes()
          INTERNAL:
 ValueReadQuery buildSelectQueryForIdentity(java.lang.String seqName, java.lang.Integer size)
          INTERNAL: Though Oracle doesn't support identity it could be immitated, see comment to setSupportsIdentity method.
 ValueReadQuery buildSelectQueryForSequenceObject(java.lang.String seqName, java.lang.Integer size)
          INTERNAL: Produce a DataReadQuery which updates(!)
 java.io.Writer buildSequenceObjectAlterIncrementWriter(java.io.Writer writer, java.lang.String fullSeqName, int increment)
          INTERNAL: Override this method if the platform supports sequence objects and isAlterSequenceObjectSupported returns true.
 java.io.Writer buildSequenceObjectCreationWriter(java.io.Writer writer, java.lang.String fullSeqName, int increment, int start)
          INTERNAL: Override this method if the platform supports sequence objects.
 java.io.Writer buildSequenceObjectDeletionWriter(java.io.Writer writer, java.lang.String fullSeqName)
          INTERNAL: Override this method if the platform supports sequence objects.
 boolean canBuildCallWithReturning()
          INTERNAL: Indicates whether the platform can build call with returning.
 boolean canUnwrapOracleConnection()
          INTERNAL: Indicates whether this Oracle platform can unwrap Oracle connection.
protected  ExpressionOperator currentDateOperator()
           
protected  ExpressionOperator currentTimeOperator()
           
 java.lang.String getAssignmentString()
          INTERNAL: Used for stored function calls.
 java.lang.String getBatchBeginString()
          Used for batch writing and sp defs.
 java.lang.String getBatchEndString()
          Used for batch writing and sp defs.
 java.lang.String getDeclareBeginString()
          INTERNAL: DECLARE stanza header for Anonymous PL/SQL block
 int getMaxFieldNameSize()
          INTERNAL: returns the maximum number of characters that can be used in a field name on this platform.
 java.util.Vector getNativeTableInfo(java.lang.String table, java.lang.String creator, AbstractSession session)
          Return the catalog information through using the native SQL catalog selects.
 java.lang.Object getObjectFromResultSet(java.sql.ResultSet resultSet, int columnNumber, int type, AbstractSession session)
          INTERNAL: Get a timestamp value from a result set.
 java.lang.String getProcedureArgumentSetter()
          Used for sp calls.
 java.lang.String getProcedureCallHeader()
          Used for sp calls.
 java.lang.String getProcedureCallTail()
          Used for sp calls.
protected  java.lang.String getQualifiedSequenceName(java.lang.String seqName)
          Prepend sequence name with table qualifier (if any)
 java.lang.String getSelectForUpdateString()
           
 java.lang.String getStoredProcedureParameterPrefix()
           
 java.lang.String getStoredProcedureTerminationToken()
           
 ValueReadQuery getSystemChangeNumberQuery()
          PUBLIC: The query to select the current system change number from Oracle.
 ValueReadQuery getTimestampQuery()
          PUBLIC: This method returns the query to select the timestamp from the server for Oracle.
protected  void initializePlatformOperators()
          Initialize any platform-specific operators
 boolean isAlterSequenceObjectSupported()
          INTERNAL: Override this method if the platform supports sequence objects and it's possible to alter sequence object's increment in the database.
 boolean isOracle()
           
protected  ExpressionOperator logOperator()
          Create the log operator for this platform
 java.util.Hashtable maximumNumericValues()
          Builds a table of maximum numeric values keyed on java class.
 java.util.Hashtable minimumNumericValues()
          Builds a table of minimum numeric values keyed on java class.
protected  ExpressionOperator operatorLocate()
          INTERNAL: Override the default locate operator
protected  ExpressionOperator operatorLocate2()
          INTERNAL: Override the default locate operator
protected  ExpressionOperator operatorOuterJoin()
          Create the outer join operator for this platform
 void printFieldNullClause(java.io.Writer writer)
          INTERNAL: Append the receiver's field 'NULL' constraint clause to a writer.
 void printSQLSelectStatement(DatabaseCall call, ExpressionSQLPrinter printer, SQLSelectStatement statement)
          INTERNAL: Print the SQL representation of the statement on a stream, storing the fields in the DatabaseCall.
 java.lang.String serverTimestampString()
          Return the current date and time from the server.
 void setShouldUseRownumFiltering(boolean useRownumFiltering)
          PUBLIC: Set if Oracle ROWNUM pagination should be used for FirstResult and MaxRows settings.
 void setSupportsIdentity(boolean supportsIdentity)
          ADVANCED: Oracle db doesn't support identity.
 boolean shouldPrintOuterJoinInWhereClause()
          Some database require outer joins to be given in the where clause, others require it in the from clause.
 boolean shouldUseJDBCOuterJoinSyntax()
          JDBC defines and outer join syntax, many drivers do not support this.
 boolean shouldUseRownumFiltering()
          PUBLIC: Return if Oracle ROWNUM pagination should be used for FirstResult and MaxRows settings.
 boolean supportsIdentity()
          INTERNAL: Indicates whether the platform supports identity.
 boolean supportsSelectForUpdateNoWait()
          Returns true if the database supports SQL syntax not to wait on a SELECT..FOR UPADTE (i.e.
 boolean supportsSequenceObjects()
          INTERNAL: Indicates whether the platform supports sequence objects.
 boolean supportsStoredFunctions()
          INTERNAL: Return if database stored functions are supported.
protected  ExpressionOperator todayOperator()
          Create the sysdate operator for this platform
 java.sql.Connection unwrapOracleConnection(java.sql.Connection connection)
          INTERNAL: If can unwrap returns unwrapped Oracle connection, otherwise original connection.
 boolean wasFailureCommunicationBased(java.sql.SQLException exception, java.sql.Connection connection, AbstractSession sessionForProfile)
          INTERNAL: A call to this method will perform a platform based check on the connection and exception error code to dermine if the connection is still valid or if a communication error has occurred.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

useRownumFiltering

protected boolean useRownumFiltering
Oracle's Rownum can be used to limit results and for pagination, using the query's maxRows and FirstResult settings


supportsIdentity

protected boolean supportsIdentity
Advanced attribute indicating whether identity is supported, see comment to setSupportsIdentity method.

Constructor Detail

OraclePlatform

public OraclePlatform()
Method Detail

allowsSizeInProcedureArguments

public boolean allowsSizeInProcedureArguments()

appendByteArray

protected void appendByteArray(byte[] bytes,
                               java.io.Writer writer)
                        throws java.io.IOException
INTERNAL: If using native SQL then print a byte[] literally as a hex string otherwise use ODBC format as provided in DatabasePlatform.

Throws:
java.io.IOException

appendDate

protected void appendDate(java.sql.Date date,
                          java.io.Writer writer)
                   throws java.io.IOException
INTERNAL: Appends an Oracle specific date if usesNativeSQL is true otherwise use the ODBC format. Native FORMAT: to_date('1997-11-06','yyyy-mm-dd')

Throws:
java.io.IOException

appendTime

protected void appendTime(java.sql.Time time,
                          java.io.Writer writer)
                   throws java.io.IOException
INTERNAL: Appends an Oracle specific time if usesNativeSQL is true otherwise use the ODBC format. Native FORMAT: to_date(#####, 'sssss').

Throws:
java.io.IOException

appendTimestamp

protected void appendTimestamp(java.sql.Timestamp timestamp,
                               java.io.Writer writer)
                        throws java.io.IOException
INTERNAL: Appends an Oracle specific Timestamp, if usesNativeSQL is true otherwise use the ODBC format. Native Format: to_date ('1997-11-06 10:35:45.0' , 'yyyy-mm-dd hh:mm:ss.n')

Throws:
java.io.IOException

appendCalendar

protected void appendCalendar(java.util.Calendar calendar,
                              java.io.Writer writer)
                       throws java.io.IOException
INTERNAL: Appends an Oracle specific Timestamp, if usesNativeSQL is true otherwise use the ODBC format. Native Format: to_date ('1997-11-06 10:35:45.0' , 'yyyy-mm-dd hh:mm:ss.n')

Throws:
java.io.IOException

atan2Operator

public ExpressionOperator atan2Operator()
INTERNAL: Build operator.


buildFieldTypes

protected java.util.Hashtable buildFieldTypes()
INTERNAL:


buildCallWithReturning

public DatabaseCall buildCallWithReturning(SQLCall sqlCall,
                                           java.util.Vector returnFields)
INTERNAL: Returns null unless the platform supports call with returning


canBuildCallWithReturning

public boolean canBuildCallWithReturning()
INTERNAL: Indicates whether the platform can build call with returning. In case this method returns true, buildCallWithReturning method may be called.


getAssignmentString

public java.lang.String getAssignmentString()
INTERNAL: Used for stored function calls.


getDeclareBeginString

public java.lang.String getDeclareBeginString()
INTERNAL: DECLARE stanza header for Anonymous PL/SQL block


getBatchBeginString

public java.lang.String getBatchBeginString()
Used for batch writing and sp defs.


getBatchEndString

public java.lang.String getBatchEndString()
Used for batch writing and sp defs.


getMaxFieldNameSize

public int getMaxFieldNameSize()
INTERNAL: returns the maximum number of characters that can be used in a field name on this platform.


getNativeTableInfo

public java.util.Vector getNativeTableInfo(java.lang.String table,
                                           java.lang.String creator,
                                           AbstractSession session)
Return the catalog information through using the native SQL catalog selects. This is required because many JDBC driver do not support meta-data. Willcards can be passed as arguments.


getProcedureArgumentSetter

public java.lang.String getProcedureArgumentSetter()
Used for sp calls.


getProcedureCallHeader

public java.lang.String getProcedureCallHeader()
Used for sp calls.


getProcedureCallTail

public java.lang.String getProcedureCallTail()
Used for sp calls.


getSelectForUpdateString

public java.lang.String getSelectForUpdateString()

getStoredProcedureParameterPrefix

public java.lang.String getStoredProcedureParameterPrefix()

getStoredProcedureTerminationToken

public java.lang.String getStoredProcedureTerminationToken()

getSystemChangeNumberQuery

public ValueReadQuery getSystemChangeNumberQuery()
PUBLIC: The query to select the current system change number from Oracle. In order to execute this query a database administrator may need to grant execute permission on pl/sql package DBMS_FLASHBACK.


getTimestampQuery

public ValueReadQuery getTimestampQuery()
PUBLIC: This method returns the query to select the timestamp from the server for Oracle.


getObjectFromResultSet

public java.lang.Object getObjectFromResultSet(java.sql.ResultSet resultSet,
                                               int columnNumber,
                                               int type,
                                               AbstractSession session)
                                        throws java.sql.SQLException
INTERNAL: Get a timestamp value from a result set. Overrides the default behavior to specifically return a timestamp. Added to overcome an issue with the oracle 9.0.1.4 JDBC driver.

Throws:
java.sql.SQLException

initializePlatformOperators

protected void initializePlatformOperators()
Initialize any platform-specific operators


isOracle

public boolean isOracle()

logOperator

protected ExpressionOperator logOperator()
Create the log operator for this platform


maximumNumericValues

public java.util.Hashtable maximumNumericValues()
Builds a table of maximum numeric values keyed on java class. This is used for type testing but might also be useful to end users attempting to sanitize values.

NOTE: BigInteger & BigDecimal maximums are dependent upon their precision & Scale


minimumNumericValues

public java.util.Hashtable minimumNumericValues()
Builds a table of minimum numeric values keyed on java class. This is used for type testing but might also be useful to end users attempting to sanitize values.

NOTE: BigInteger & BigDecimal minimums are dependent upon their precision & Scale


buildSelectQueryForSequenceObject

public ValueReadQuery buildSelectQueryForSequenceObject(java.lang.String seqName,
                                                        java.lang.Integer size)
INTERNAL: Produce a DataReadQuery which updates(!) the sequence number in the db and returns it. Currently implemented on Oracle only.

Parameters:
sequenceName - Name known by Oracle to be a defined sequence

buildSelectQueryForIdentity

public ValueReadQuery buildSelectQueryForIdentity(java.lang.String seqName,
                                                  java.lang.Integer size)
INTERNAL: Though Oracle doesn't support identity it could be immitated, see comment to setSupportsIdentity method.

Parameters:
sequenceName - Name known by Oracle to be a defined sequence

getQualifiedSequenceName

protected java.lang.String getQualifiedSequenceName(java.lang.String seqName)
Prepend sequence name with table qualifier (if any)


operatorOuterJoin

protected ExpressionOperator operatorOuterJoin()
Create the outer join operator for this platform


operatorLocate

protected ExpressionOperator operatorLocate()
INTERNAL: Override the default locate operator


operatorLocate2

protected ExpressionOperator operatorLocate2()
INTERNAL: Override the default locate operator


printFieldNullClause

public void printFieldNullClause(java.io.Writer writer)
                          throws ValidationException
INTERNAL: Append the receiver's field 'NULL' constraint clause to a writer.

Throws:
ValidationException

serverTimestampString

public java.lang.String serverTimestampString()
Return the current date and time from the server.


setShouldUseRownumFiltering

public void setShouldUseRownumFiltering(boolean useRownumFiltering)
PUBLIC: Set if Oracle ROWNUM pagination should be used for FirstResult and MaxRows settings. Default is false.


shouldPrintOuterJoinInWhereClause

public boolean shouldPrintOuterJoinInWhereClause()
Some database require outer joins to be given in the where clause, others require it in the from clause.


shouldUseJDBCOuterJoinSyntax

public boolean shouldUseJDBCOuterJoinSyntax()
JDBC defines and outer join syntax, many drivers do not support this. So we normally avoid it.


shouldUseRownumFiltering

public boolean shouldUseRownumFiltering()
PUBLIC: Return if Oracle ROWNUM pagination should be used for FirstResult and MaxRows settings. Default is false.


supportsSequenceObjects

public boolean supportsSequenceObjects()
INTERNAL: Indicates whether the platform supports sequence objects. This method is to be used *ONLY* by sequencing classes


supportsIdentity

public boolean supportsIdentity()
INTERNAL: Indicates whether the platform supports identity. This method is to be used *ONLY* by sequencing classes


setSupportsIdentity

public void setSupportsIdentity(boolean supportsIdentity)
ADVANCED: Oracle db doesn't support identity. However it's possible to get identity-like behaviour using sequence in an insert trigger - that's the only case when supportsIdentity should be set to true: in this case all the sequences that have shouldAcquireValueAfterInsert set to true will keep this setting (it would've been reversed in case identity is not supported). Note that with supportsIdentity==true attempt to create tables that have identity fields will fail - Oracle doesn't support identity. Therefore if there's table creation reqiured it should be done with supportsIdentity==false, then set the flag to true and reset sequencing (or logout and login the session).


supportsStoredFunctions

public boolean supportsStoredFunctions()
INTERNAL: Return if database stored functions are supported.


supportsSelectForUpdateNoWait

public boolean supportsSelectForUpdateNoWait()
Returns true if the database supports SQL syntax not to wait on a SELECT..FOR UPADTE (i.e. In Oracle adding NOWAIT to the end will accomplish this)


todayOperator

protected ExpressionOperator todayOperator()
Create the sysdate operator for this platform


currentDateOperator

protected ExpressionOperator currentDateOperator()

currentTimeOperator

protected ExpressionOperator currentTimeOperator()

canUnwrapOracleConnection

public boolean canUnwrapOracleConnection()
INTERNAL: Indicates whether this Oracle platform can unwrap Oracle connection.


unwrapOracleConnection

public java.sql.Connection unwrapOracleConnection(java.sql.Connection connection)
INTERNAL: If can unwrap returns unwrapped Oracle connection, otherwise original connection.


printSQLSelectStatement

public void printSQLSelectStatement(DatabaseCall call,
                                    ExpressionSQLPrinter printer,
                                    SQLSelectStatement statement)
INTERNAL: Print the SQL representation of the statement on a stream, storing the fields in the DatabaseCall. This implementation works MaxRows and FirstResult into the SQL using Oracle's ROWNUM to filter values if shouldUseRownumFiltering is true.


buildSequenceObjectCreationWriter

public java.io.Writer buildSequenceObjectCreationWriter(java.io.Writer writer,
                                                        java.lang.String fullSeqName,
                                                        int increment,
                                                        int start)
                                                 throws java.io.IOException
INTERNAL: Override this method if the platform supports sequence objects. Returns sql used to create sequence object in the database.

Throws:
java.io.IOException

buildSequenceObjectDeletionWriter

public java.io.Writer buildSequenceObjectDeletionWriter(java.io.Writer writer,
                                                        java.lang.String fullSeqName)
                                                 throws java.io.IOException
INTERNAL: Override this method if the platform supports sequence objects. Returns sql used to delete sequence object from the database.

Throws:
java.io.IOException

buildSequenceObjectAlterIncrementWriter

public java.io.Writer buildSequenceObjectAlterIncrementWriter(java.io.Writer writer,
                                                              java.lang.String fullSeqName,
                                                              int increment)
                                                       throws java.io.IOException
INTERNAL: Override this method if the platform supports sequence objects and isAlterSequenceObjectSupported returns true. Returns sql used to alter sequence object's increment in the database.

Throws:
java.io.IOException

isAlterSequenceObjectSupported

public boolean isAlterSequenceObjectSupported()
INTERNAL: Override this method if the platform supports sequence objects and it's possible to alter sequence object's increment in the database.


wasFailureCommunicationBased

public boolean wasFailureCommunicationBased(java.sql.SQLException exception,
                                            java.sql.Connection connection,
                                            AbstractSession sessionForProfile)
INTERNAL: A call to this method will perform a platform based check on the connection and exception error code to dermine if the connection is still valid or if a communication error has occurred. If a communication error has occurred then the query may be retried. If this platform is unable to determine if the error was communication based it will return false forcing the error to be thrown to the user.


EclipseLink 1.0_1.0M2 API Reference - Incubation