Package org.apache.torque.adapter

# Class OracleAdapter

java.lang.Object
org.apache.torque.adapter.AbstractAdapter
org.apache.torque.adapter.OracleAdapter

All Implemented Interfaces:
  `Serializable`, `Adapter`

public class OracleAdapter extends AbstractAdapter
This code should be used for an Oracle database pool.

Version:
  $Id: OracleAdapter.java 1917245 2024-04-21 14:06:23Z tv $
Author:
  Jon S. Stevens, Brett McLaughlin, Bill Schneider, Daniel Rall
See Also:
  - Serialized Form

- ## Field Summary

  ### Fields inherited from interface org.apache.torque.adapter.Adapter

  `ADAPTER_KEY, AUTODETECT_ADAPTER, DRIVER_KEY`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `OracleAdapter()`
  Empty constructor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `escapeText()`
  This method is for the SqlExpression.quoteAndEscape rules.
  `void`
  `generateLimits(Query query, long offset, int limit)`
  Build Oracle-style query with limit or offset.
  `String`
  `getIDMethodSQL(Object sequenceName)`
  Returns SQL used to get the most recently inserted primary key.
  `IDMethod`
  `getIDMethodType()`
  Returns the constant from the `IDMethod` interface denoting which type of primary key generation method this type of RDBMS uses.
  `String`
  `ignoreCase(String in)`
  This method is used to ignore case.
  `void`
  `lockTable(Connection con, String table)`
  Locks the specified table.
  `String`
  `toUpperCase(String in)`
  This method is used to ignore case.
  `void`
  `unlockTable(Connection con, String table)`
  Unlocks the specified table.
  `boolean`
  `useEscapeClauseForLike()`
  Whether an escape clause in like should be used.
  `boolean`
  `useMinusForExcept()`
  Whether to use the MINUS operator instead of the EXCEPT operator.

  ### Methods inherited from class org.apache.torque.adapter.AbstractAdapter

  `getStringDelimiter, getUpdateLockClause, ignoreCaseInOrderBy, setCapabilities, supportsNativeLimit, supportsNativeOffset, useGetGeneratedKeys, useIlike`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### OracleAdapter

    protected OracleAdapter()
    Empty constructor.

- ## Method Details

  - ### toUpperCase

    public String toUpperCase(String in)
    This method is used to ignore case.
    Specified by:
      `toUpperCase` in interface `Adapter`
    Specified by:
      `toUpperCase` in class `AbstractAdapter`
    Parameters:
      `in` - The string to transform to upper case.
    Returns:
      The upper case string.

  - ### ignoreCase

    public String ignoreCase(String in)
    This method is used to ignore case.
    Specified by:
      `ignoreCase` in interface `Adapter`
    Specified by:
      `ignoreCase` in class `AbstractAdapter`
    Parameters:
      `in` - The string whose case to ignore.
    Returns:
      The string in a case that can be ignored.

  - ### getIDMethodType

    public IDMethod getIDMethodType()
    Description copied from class: `AbstractAdapter`
    Returns the constant from the `IDMethod` interface denoting which type of primary key generation method this type of RDBMS uses.
    Specified by:
      `getIDMethodType` in interface `Adapter`
    Specified by:
      `getIDMethodType` in class `AbstractAdapter`
    Returns:
      IDMethod constant
    See Also:
      - `Adapter.getIDMethodType()`

  - ### getIDMethodSQL

    public String getIDMethodSQL(Object sequenceName)
    Description copied from class: `AbstractAdapter`
    Returns SQL used to get the most recently inserted primary key. Databases which have no support for this return `null`.
    Specified by:
      `getIDMethodSQL` in interface `Adapter`
    Specified by:
      `getIDMethodSQL` in class `AbstractAdapter`
    Parameters:
      `sequenceName` - The name of the sequence (should be of type `String`).
    Returns:
      SQL to retrieve the next database key.
    See Also:
      - `Returns the next key from a sequence. Uses the following implementation:

                    select sequenceName.nextval from dual

        `
      - `Adapter.getIDMethodSQL(Object)`

  - ### lockTable

    public void lockTable(Connection con, String table) throws SQLException
    Locks the specified table.
    Specified by:
      `lockTable` in interface `Adapter`
    Specified by:
      `lockTable` in class `AbstractAdapter`
    Parameters:
      `con` - The JDBC connection to use.
      `table` - The name of the table to lock.
    Throws:
      `SQLException` - No Statement could be created or executed.

  - ### unlockTable

    public void unlockTable(Connection con, String table) throws SQLException
    Unlocks the specified table.
    Specified by:
      `unlockTable` in interface `Adapter`
    Specified by:
      `unlockTable` in class `AbstractAdapter`
    Parameters:
      `con` - The JDBC connection to use.
      `table` - The name of the table to unlock.
    Throws:
      `SQLException` - No Statement could be created or executed.

  - ### generateLimits

    public void generateLimits(Query query, long offset, int limit)
    Build Oracle-style query with limit or offset. If the original SQL is in variable: query then the requlting SQL looks like this:

         SELECT B.* FROM (
                  SELECT A.*, rownum as TORQUE$ROWNUM FROM (
                          query
                  ) A
             ) B WHERE B.TORQUE$ROWNUM > offset AND B.TORQUE$ROWNUM
             <= offset + limit

    Specified by:
      `generateLimits` in interface `Adapter`
    Overrides:
      `generateLimits` in class `AbstractAdapter`
    Parameters:
      `query` - The query to modify
      `offset` - the offset Value
      `limit` - the limit Value

  - ### escapeText

    public boolean escapeText()
    This method is for the SqlExpression.quoteAndEscape rules. The rule is, any string in a SqlExpression with a BACKSLASH will either be changed to "\\" or left as "\". SapDB does not need the escape character.
    Specified by:
      `escapeText` in interface `Adapter`
    Overrides:
      `escapeText` in class `AbstractAdapter`
    Returns:
      false.

  - ### useEscapeClauseForLike

    public boolean useEscapeClauseForLike()
    Whether an escape clause in like should be used. Example : select * from AUTHOR where AUTHOR.NAME like '\_%' ESCAPE '\'; Oracle needs this, so this implementation always returns `true`.
    Specified by:
      `useEscapeClauseForLike` in interface `Adapter`
    Overrides:
      `useEscapeClauseForLike` in class `AbstractAdapter`
    Returns:
      whether the escape clause should be appended or not.

  - ### useMinusForExcept

    public boolean useMinusForExcept()
    Whether to use the MINUS operator instead of the EXCEPT operator. Oracle needs this, so this implementation always returns `true`.
    Specified by:
      `useMinusForExcept` in interface `Adapter`
    Overrides:
      `useMinusForExcept` in class `AbstractAdapter`
    Returns:
      whether to use the MINUS operator instead of the EXCEPT operator.