public abstract class AbstractAdapter extends Object implements Adapter
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.
ADAPTER_KEY, AUTODETECT_ADAPTER, DRIVER_KEY| Modifier | Constructor and Description |
|---|---|
protected |
AbstractAdapter()
Empty constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
escapeText()
This method is for the SqlExpression.quoteAndEscape rules.
|
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.
|
abstract String |
getIDMethodSQL(Object obj)
Returns SQL used to get the most recently inserted primary key.
|
abstract IDMethod |
getIDMethodType()
Returns the constant from the
IDMethod interface denoting which
type of primary key generation method this type of RDBMS uses. |
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).
|
String |
getUpdateLockClause()
Returns the clause which acquires a write lock on a row
when doing a select.
|
abstract String |
ignoreCase(String in)
Wraps the input string in a database function to change it to
a case-insensitive representation.
|
String |
ignoreCaseInOrderBy(String in)
This method is used to ignore case in an ORDER BY clause.
|
abstract void |
lockTable(Connection con,
String table)
Locks the specified table.
|
void |
setCapabilities(DatabaseMetaData dmd)
Update static capabilities of the adapter with actual
readings based on the JDBC meta-data
|
boolean |
supportsNativeLimit()
Returns whether the database can natively limit the size of the ResultSet
of a query.
|
boolean |
supportsNativeOffset()
Returns whether the database natively supports returning results
starting at an offset position other than 0.
|
abstract String |
toUpperCase(String in)
Wraps the input string in a database function to change it to upper case.
|
abstract void |
unlockTable(Connection con,
String table)
Unlocks the specified table.
|
boolean |
useEscapeClauseForLike()
Whether an escape clause in like should be used.
|
boolean |
useGetGeneratedKeys()
whether Statement#getGeneratedKeys() should be used.
|
boolean |
useIlike()
Whether ILIKE should be used for case insensitive like clauses.
|
boolean |
useMinusForExcept()
Whether to use the MINUS operator instead of the EXCEPT operator.
|
public abstract String toUpperCase(String in)
toUpperCase in interface Adapterin - The string to transform to upper case, may be a literal string,
a prepared statement replacement placeholder(*) or any other
database expression.public char getStringDelimiter()
getStringDelimiter in interface Adapterpublic abstract IDMethod getIDMethodType()
IDMethod interface denoting which
type of primary key generation method this type of RDBMS uses.getIDMethodType in interface Adapterpublic abstract String getIDMethodSQL(Object obj)
null.getIDMethodSQL in interface Adapterobj - Information used for key generation.public String getUpdateLockClause()
getUpdateLockClause in interface Adapterpublic abstract void lockTable(Connection con, String table) throws SQLException
lockTable in interface Adaptercon - The JDBC connection to use.table - The name of the table to lock.SQLException - No Statement could be created or executed.public abstract void unlockTable(Connection con, String table) throws SQLException
unlockTable in interface Adaptercon - The JDBC connection to use.table - The name of the table to unlock.SQLException - No Statement could be created or executed.public abstract String ignoreCase(String in)
ignoreCase in interface Adapterin - The string to transform to a case-insensitive representation,
may be a literal string, a prepared statement replacement
placeholder(*) or any other database expression.public String ignoreCaseInOrderBy(String in)
ignoreCaseInOrderBy in interface Adapterin - The string whose case to ignore.public boolean supportsNativeLimit()
supportsNativeLimit in interface Adapterpublic boolean supportsNativeOffset()
supportsNativeOffset in interface Adapterpublic void generateLimits(Query query, long offset, int limit) throws TorqueException
generateLimits in interface Adapterquery - The query to modifyoffset - the offset Valuelimit - the limit ValueTorqueException - if any error occurs when building the querypublic boolean escapeText()
escapeText in interface Adapterpublic boolean useIlike()
public boolean useEscapeClauseForLike()
false. This behaviour can be overwritten
in subclasses.useEscapeClauseForLike in interface Adapterpublic boolean useMinusForExcept()
false.
This behaviour can be overwritten in subclasses.useMinusForExcept in interface Adapterpublic boolean useGetGeneratedKeys()
useGetGeneratedKeys in interface Adapterboolean valuepublic void setCapabilities(DatabaseMetaData dmd) throws SQLException
setCapabilities in interface Adapterdmd - database meta dataSQLException - if there are problems getting the JDBC meta dataCopyright © 2000–2020 The Apache Software Foundation. All rights reserved.