Package org.apache.torque.adapter
Schnittstelle Adapter
- Alle Superschnittstellen:
Serializable
- Alle bekannten Implementierungsklassen:
AbstractAdapter
,DerbyAdapter
,HsqldbAdapter
,MssqlAdapter
,MysqlAdapter
,NoneAdapter
,OracleAdapter
,PostgresAdapter
DB
defines the interface for a Torque database
adapter. Support for new databases is added by implementing this
interface. A couple of default settings is provided by
subclassing AbstractDBAdapter
. The new database adapter
and its corresponding JDBC driver need to be registered in the service
configuration file.
The Torque database adapters exist to present a uniform interface to database access across all available databases. Once the necessary adapters have been written and configured, transparent swapping of databases is theoretically supported with zero code changes and minimal configuration file modifications. All database adapters need to be thread safe, as they are instantiated only once fore a given configured database and may be accessed simultaneously from several threads. *
- Version:
- $Id: Adapter.java 1850586 2019-01-06 18:46:35Z tv $
- Autor:
- Jon S. Stevens, Brett McLaughlin, Daniel Rall, Augustin Vidovic, Thomas Vandahl, Greg Monroe
-
Feldübersicht
Felder -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungboolean
Determines whether backslashes (\) should be escaped in explicit SQL strings.void
generateLimits
(Query query, long offset, int limit) This method is used to generate the database specific query extension to limit the number of record returned.getIDMethodSQL
(Object obj) Returns SQL used to get the most recently inserted primary key.Returns the constant from theIDMethod
interface denoting which type of primary key generation method this type of RDBMS uses.char
Returns the character used to indicate the beginning and end of a piece of text used in a SQL statement (generally a single quote).Returns the clause which acquires a write lock on a row when doing a select.ignoreCase
(String in) Wraps the input string in a database function to change it to a case-insensitive representation.This method is used to ignore case in an ORDER BY clause.void
lockTable
(Connection con, String table) Locks the specified table.void
Update static capabilities of the adapter with actual readings based on the JDBC meta-databoolean
This method is used to check whether the database natively supports limiting the size of the resultset.boolean
This method is used to check whether the database natively supports returning results starting at an offset position other than 0.toUpperCase
(String in) Wraps the input string in a database function to change it to upper case.void
unlockTable
(Connection con, String table) Unlocks the specified table.boolean
Whether an escape clause in like should be used.boolean
whether Statement#getGeneratedKeys() should be used.boolean
useIlike()
Whether ILIKE should be used for case insensitive like clauses.boolean
Whether to use the MINUS operator instead of the EXCEPT operator.
-
Felddetails
-
ADAPTER_KEY
Key for the configuration which contains database adapters.- Siehe auch:
-
DRIVER_KEY
Key for the configuration which contains database drivers.- Siehe auch:
-
AUTODETECT_ADAPTER
Special adapter for auto-detection.- Siehe auch:
-
-
Methodendetails
-
toUpperCase
Wraps the input string in a database function to change it to upper case.- Parameter:
in
- The string to transform to upper case, may be a literal string, a prepared statement replacement placeholder(*) or any other database expression.- Gibt zurück:
- The wrapped input string, so that the database evaluates the returned expression to the upper case of the input.
-
getStringDelimiter
char getStringDelimiter()Returns the character used to indicate the beginning and end of a piece of text used in a SQL statement (generally a single quote).- Gibt zurück:
- The text delimiter.
-
getIDMethodType
IDMethod getIDMethodType()Returns the constant from theIDMethod
interface denoting which type of primary key generation method this type of RDBMS uses.- Gibt zurück:
- IDMethod constant
-
getIDMethodSQL
Returns SQL used to get the most recently inserted primary key. Databases which have no support for this returnnull
.- Parameter:
obj
- Information used for key generation.- Gibt zurück:
- The most recently inserted database key.
-
getUpdateLockClause
String getUpdateLockClause()Returns the clause which acquires a write lock on a row when doing a select. Most databases use the "for update" clause.- Gibt zurück:
- the SQL clause to acquire a write lock.
-
lockTable
Locks the specified table.- Parameter:
con
- The JDBC connection to use.table
- The name of the table to lock.- Löst aus:
SQLException
- No Statement could be created or executed.
-
unlockTable
Unlocks the specified table.- Parameter:
con
- The JDBC connection to use.table
- The name of the table to unlock.- Löst aus:
SQLException
- No Statement could be created or executed.
-
ignoreCase
Wraps the input string in a database function to change it to a case-insensitive representation.- Parameter:
in
- The string to transform to a case-insensitive representation, may be a literal string, a prepared statement replacement placeholder(*) or any other database expression.- Gibt zurück:
- The wrapped input string, so that the database evaluates the returned expression to a case-insensitive representation of the input.
-
ignoreCaseInOrderBy
This method is used to ignore case in an ORDER BY clause. Usually it is the same as ignoreCase, but some databases (hsqldb for example) does not use the same SQL in ORDER BY and other clauses.- Parameter:
in
- The string whose case to ignore.- Gibt zurück:
- The string in a case that can be ignored.
-
supportsNativeLimit
boolean supportsNativeLimit()This method is used to check whether the database natively supports limiting the size of the resultset.- Gibt zurück:
- true if the database natively supports limiting the size of the resultset.
-
supportsNativeOffset
boolean supportsNativeOffset()This method is used to check whether the database natively supports returning results starting at an offset position other than 0.- Gibt zurück:
- true if the database natively supports returning results starting at an offset position other than 0.
-
generateLimits
This method is used to generate the database specific query extension to limit the number of record returned.- Parameter:
query
- The query to modifyoffset
- the offset Valuelimit
- the limit Value- Löst aus:
TorqueException
- if any error occurs when building the query
-
escapeText
boolean escapeText()Determines whether backslashes (\) should be escaped in explicit SQL strings. If true is returned, a BACKSLASH will be changed to "\\". If false is returned, a BACKSLASH will be left as "\".- Gibt zurück:
- true if the database needs to escape backslashes in SqlExpressions.
-
useIlike
boolean useIlike()Whether ILIKE should be used for case insensitive like clauses.- Gibt zurück:
- true if ilike should be used for case insensitive likes, false if ignoreCase should be applied to the compared strings.
-
useEscapeClauseForLike
boolean useEscapeClauseForLike()Whether an escape clause in like should be used. Example : select * from AUTHOR where AUTHOR.NAME like '\_%' ESCAPE '\';- Gibt zurück:
- whether the escape clause should be appended or not.
-
useMinusForExcept
boolean useMinusForExcept()Whether to use the MINUS operator instead of the EXCEPT operator.- Gibt zurück:
- whether to use the MINUS operator instead of the EXCEPT operator.
-
useGetGeneratedKeys
boolean useGetGeneratedKeys()whether Statement#getGeneratedKeys() should be used.- Gibt zurück:
- a
boolean
value
-
setCapabilities
Update static capabilities of the adapter with actual readings based on the JDBC meta-data- Parameter:
dmd
- database meta data- Löst aus:
SQLException
- if there are problems getting the JDBC meta data
-