Package org.apache.torque.adapter
Klasse AbstractAdapter
java.lang.Object
org.apache.torque.adapter.AbstractAdapter
- Alle implementierten Schnittstellen:
Serializable,Adapter
- Bekannte direkte Unterklassen:
DerbyAdapter,HsqldbAdapter,MssqlAdapter,MysqlAdapter,NoneAdapter,OracleAdapter,PostgresAdapter
This class is the abstract base for any database adapter
Support for new databases is added by subclassing this
class and implementing its abstract methods, and by
registering the new database adapter and its corresponding
JDBC driver 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.
- Version:
- $Id: AbstractAdapter.java 1917245 2024-04-21 14:06:23Z tv $
- Autor:
- Jon S. Stevens, Brett McLaughlin, Daniel Rall, Augustin Vidovic, Greg Monroe
- Siehe auch:
-
Feldübersicht
Von Schnittstelle geerbte Felder org.apache.torque.adapter.Adapter
ADAPTER_KEY, AUTODETECT_ADAPTER, DRIVER_KEY -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungbooleanThis method is for the SqlExpression.quoteAndEscape rules.voidgenerateLimits(Query query, long offset, int limit) This method is used to generate the database specific query extension to limit the number of record returned.abstract StringgetIDMethodSQL(Object obj) Returns SQL used to get the most recently inserted primary key.abstract IDMethodReturns the constant from theIDMethodinterface denoting which type of primary key generation method this type of RDBMS uses.charReturns 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.abstract StringignoreCase(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.abstract voidlockTable(Connection con, String table) Locks the specified table.voidUpdate static capabilities of the adapter with actual readings based on the JDBC meta-databooleanReturns whether the database can natively limit the size of the ResultSet of a query.booleanReturns whether the database natively supports returning results starting at an offset position other than 0.abstract StringtoUpperCase(String in) Wraps the input string in a database function to change it to upper case.abstract voidunlockTable(Connection con, String table) Unlocks the specified table.booleanWhether an escape clause in like should be used.booleanwhether Statement#getGeneratedKeys() should be used.booleanuseIlike()Whether ILIKE should be used for case insensitive like clauses.booleanWhether to use the MINUS operator instead of the EXCEPT operator.
-
Konstruktordetails
-
AbstractAdapter
protected AbstractAdapter()Empty constructor.
-
-
Methodendetails
-
toUpperCase
Wraps the input string in a database function to change it to upper case.- Angegeben von:
toUpperCasein SchnittstelleAdapter- 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
public 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).- Angegeben von:
getStringDelimiterin SchnittstelleAdapter- Gibt zurück:
- The text delimiter.
-
getIDMethodType
Returns the constant from theIDMethodinterface denoting which type of primary key generation method this type of RDBMS uses.- Angegeben von:
getIDMethodTypein SchnittstelleAdapter- 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.- Angegeben von:
getIDMethodSQLin SchnittstelleAdapter- Parameter:
obj- Information used for key generation.- Gibt zurück:
- The most recently inserted database key.
-
getUpdateLockClause
Returns the clause which acquires a write lock on a row when doing a select.- Angegeben von:
getUpdateLockClausein SchnittstelleAdapter- Gibt zurück:
- the SQL clause to acquire a write lock. This implementation returns "FOR UPDATE";
-
lockTable
Locks the specified table.- Angegeben von:
lockTablein SchnittstelleAdapter- 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.- Angegeben von:
unlockTablein SchnittstelleAdapter- 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.- Angegeben von:
ignoreCasein SchnittstelleAdapter- 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) do not use the same SQL in ORDER BY and other clauses.- Angegeben von:
ignoreCaseInOrderByin SchnittstelleAdapter- Parameter:
in- The string whose case to ignore.- Gibt zurück:
- The string in a case that can be ignored.
-
supportsNativeLimit
public boolean supportsNativeLimit()Returns whether the database can natively limit the size of the ResultSet of a query.- Angegeben von:
supportsNativeLimitin SchnittstelleAdapter- Gibt zurück:
- true if the database natively supports limiting the size of the resultset.
-
supportsNativeOffset
public boolean supportsNativeOffset()Returns whether the database natively supports returning results starting at an offset position other than 0.- Angegeben von:
supportsNativeOffsetin SchnittstelleAdapter- 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.- Angegeben von:
generateLimitsin SchnittstelleAdapter- 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
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 "\".- Angegeben von:
escapeTextin SchnittstelleAdapter- Gibt zurück:
- true if the database needs to escape text in SqlExpressions.
-
useIlike
public boolean useIlike()Whether ILIKE should be used for case insensitive like clauses. As most databases do not use ILIKE, this implementation returns false. This behaviour may be overwritten in subclasses. -
useEscapeClauseForLike
public boolean useEscapeClauseForLike()Whether an escape clause in like should be used. Example : select * from AUTHOR where AUTHOR.NAME like '\_%' ESCAPE '\'; As most databases do not need the escape clause, this implementation always returnsfalse. This behaviour can be overwritten in subclasses.- Angegeben von:
useEscapeClauseForLikein SchnittstelleAdapter- Gibt zurück:
- whether the escape clause should be appended or not.
-
useMinusForExcept
public boolean useMinusForExcept()Whether to use the MINUS operator instead of the EXCEPT operator. As most databases do not need to replace the EXCEPT operator by the MINUS operator, this implementation always returnsfalse. This behaviour can be overwritten in subclasses.- Angegeben von:
useMinusForExceptin SchnittstelleAdapter- Gibt zurück:
- whether to use the MINUS operator instead of the EXCEPT operator.
-
useGetGeneratedKeys
public boolean useGetGeneratedKeys()whether Statement#getGeneratedKeys() should be used.- Angegeben von:
useGetGeneratedKeysin SchnittstelleAdapter- Gibt zurück:
- a
booleanvalue
-
setCapabilities
Update static capabilities of the adapter with actual readings based on the JDBC meta-data- Angegeben von:
setCapabilitiesin SchnittstelleAdapter- Parameter:
dmd- database meta data- Löst aus:
SQLException- if there are problems getting the JDBC meta data
-