public abstract class JdbcAdaptor extends AbstractJdbcAdaptor
| Modifier and Type | Class and Description |
|---|---|
static class |
JdbcAdaptor.PaginationParamsOrder
The order of pagination paramaters embedded into the SQL.
|
| Constructor and Description |
|---|
JdbcAdaptor() |
| Modifier and Type | Method and Description |
|---|---|
abstract String |
applyConcat(List<String> arguments)
Applies the concat operation to the arguments.
|
abstract String |
applyLikeEscape(String escapePattern)
Appends the escape pattern.
|
abstract String |
applyLock(String sql,
LockModeType lockMode)
Applies the lock to SQL string.
|
abstract String |
applyPagination(String sql,
int startPosition,
int maxResult)
Applies the pagination to SQL string.
|
String |
applySubStr(String innerFragment,
String startFragment,
String endFragment)
Returns the sub string function.
|
String |
applyTrim(CriteriaBuilder.Trimspec trimspec,
String trimChar,
String argument)
Applies the trim to argument
|
String |
castBoolean(String sqlFragment)
Casts the expression to boolean if necessary.
|
abstract String |
createColumnDDL(AbstractColumn columnDefinition)
Creates the BasicColumn Definition DDL For the column.
|
String |
createCreateTableStatement(AbstractTable table,
List<String> ddlColumns,
List<String> pkColumns)
Creates the create table statement
|
void |
createForeignKey(DataSourceImpl datasource,
ForeignKey foreignKey)
Creates a foreign key on the table
|
protected void |
createIndex(DataSourceImpl datasource,
EntityTable table,
String indexName,
BasicColumn[] columns)
Creates the index for the table.
|
void |
createOrUpdateTable(AbstractTable table,
DataSourceImpl datasource,
DDLMode ddlMode)
Creates or update the table.
|
abstract void |
createSequenceIfNecessary(DataSource datasource,
SequenceGenerator sequence)
Creates the sequence if not exists.
|
void |
createTableGeneratorIfNecessary(DataSourceImpl datasource,
TableGenerator table)
Creates the table generator if not exists.
|
void |
dropAllForeignKeys(DataSourceImpl datasource,
Set<AbstractTable> tables) |
void |
dropAllSequences(DataSourceImpl datasource,
Collection<SequenceGenerator> sequences) |
void |
dropAllTables(DataSourceImpl datasource,
Collection<AbstractTable> tables)
Drops the tables in the database
|
protected void |
dropSequence(QueryRunner runner,
SequenceGenerator sequence)
Drops the sequence.
|
String |
escape(String name)
Escapes an SQL name
|
protected Collection<AbstractColumn> |
getColumns(AbstractTable table)
Returns the sorted columns.
|
protected String |
getColumnType(AbstractColumn cd,
int sqlType)
Returns the data type of the column.
|
String |
getCurrentDate()
Returns the current date literal
|
String |
getCurrentTime()
Returns the current time literal
|
String |
getCurrentTimeStamp()
Returns the current time stamp literal
|
protected abstract String |
getDatabaseName() |
protected String |
getDropForeignKeySql(String schema,
String table,
String foreignKey)
Returns the SQL to drop the foreign key.
|
abstract long |
getNextSequence(DataSourceImpl datasource,
String sequenceName)
Returns next sequence number from the database.
|
String |
getNumericFunctionTemplate(NumericFunctionExpression.NumericFunctionType type)
Returns the numeric function template.
|
abstract JdbcAdaptor.PaginationParamsOrder |
getPaginationParamsOrder()
Returns the pagination params order for the adaptor.
|
protected String |
getPkCreateSql(String schema,
String table,
Set<String> pkColumns)
Returns the priary key drop SQL.
|
protected String |
getPkDropSql(String schema,
String table,
String pkName)
Returns the priary key drop SQL.
|
abstract String |
getSelectLastIdentitySql(PkColumn identityColumn)
Returns the SQL to select the last identity generated.
|
boolean |
isPmdBroken()
Returns if the PMD is Broken for the adaptor.
|
protected void |
logRelaxed(SQLException e,
String message)
Logs the message as warning and with exception as debug.
|
abstract boolean |
paginationNeedsMaxResultsAlways()
Returns if pagination always needs the max results paramater.
|
abstract boolean |
paginationNeedsStartAlways()
Returns if pagination always needs the start paramater.
|
protected String |
qualified(String schema,
String jdbcClassName)
Returns the schema if it is set otherwise falls back to the default schema.
|
abstract IdType |
supports(GenerationType type)
Returns the id type supported.
|
getAdapter, getProductNamespublic abstract String applyConcat(List<String> arguments)
arguments - the argumentspublic abstract String applyLikeEscape(String escapePattern)
escapePattern - the escape patternpublic abstract String applyLock(String sql, LockModeType lockMode)
sql - the SQL to applylockMode - the lock modepublic abstract String applyPagination(String sql, int startPosition, int maxResult)
sql - the SQL to applystartPosition - the start positionmaxResult - the max number of resultspublic String applySubStr(String innerFragment, String startFragment, String endFragment)
innerFragment - the inner fragmentstartFragment - the start fragmentendFragment - the end fragmentpublic String applyTrim(CriteriaBuilder.Trimspec trimspec, String trimChar, String argument)
trimspec - the trim spectrimChar - the trim characterargument - the argumentpublic String castBoolean(String sqlFragment)
sqlFragment - the SQL Fragmentpublic abstract String createColumnDDL(AbstractColumn columnDefinition)
columnDefinition - the column definition to create the DDL frompublic String createCreateTableStatement(AbstractTable table, List<String> ddlColumns, List<String> pkColumns)
table - the definition of the tableddlColumns - the DDL for the columnspkColumns - the list of primary key column namespublic void createForeignKey(DataSourceImpl datasource, ForeignKey foreignKey)
datasource - the datasourceforeignKey - the foreign keyprotected void createIndex(DataSourceImpl datasource, EntityTable table, String indexName, BasicColumn[] columns) throws SQLException
datasource - the datasourcetable - the tableindexName - the name of the indexcolumns - the columnsSQLException - throw in case index creation failspublic void createOrUpdateTable(AbstractTable table, DataSourceImpl datasource, DDLMode ddlMode)
table - the tabledatasource - the datasourceddlMode - the ddl modepublic abstract void createSequenceIfNecessary(DataSource datasource, SequenceGenerator sequence)
datasource - the datasource to usesequence - the sequence to createpublic final void createTableGeneratorIfNecessary(DataSourceImpl datasource, TableGenerator table)
datasource - the datasource to usetable - the table generatorpublic void dropAllForeignKeys(DataSourceImpl datasource, Set<AbstractTable> tables)
datasource - the datasourcetables - the foreign keyspublic void dropAllSequences(DataSourceImpl datasource, Collection<SequenceGenerator> sequences) throws SQLException
datasource - the datasourcesequences - the sequencesSQLException - thrown if the SQL failspublic void dropAllTables(DataSourceImpl datasource, Collection<AbstractTable> tables) throws SQLException
datasource - the datasourcetables - the set of tables to dropSQLException - thrown if the SQL failsprotected void dropSequence(QueryRunner runner, SequenceGenerator sequence) throws SQLException
runner - the runnersequence - the sequenceSQLException - thrown if SQL failspublic String escape(String name)
name - the original nameprotected Collection<AbstractColumn> getColumns(AbstractTable table)
table - the tableprotected String getColumnType(AbstractColumn cd, int sqlType)
cd - the column definitionsqlType - the sql typepublic String getCurrentDate()
public String getCurrentTime()
public String getCurrentTimeStamp()
protected abstract String getDatabaseName()
protected String getDropForeignKeySql(String schema, String table, String foreignKey)
schema - the name of the schematable - the name of the tableforeignKey - the name of the foreign keypublic abstract long getNextSequence(DataSourceImpl datasource, String sequenceName) throws SQLException
datasource - the datasource to usesequenceName - the name of the sequenceSQLException - thrown in case of an SQL errorpublic String getNumericFunctionTemplate(NumericFunctionExpression.NumericFunctionType type)
public abstract JdbcAdaptor.PaginationParamsOrder getPaginationParamsOrder()
protected String getPkCreateSql(String schema, String table, Set<String> pkColumns)
schema - the name of the schematable - the name of the tablepkColumns - the set of the primary key column namesprotected String getPkDropSql(String schema, String table, String pkName)
schema - the name of the schematable - the name of the tablepkName - the name of the primary keypublic abstract String getSelectLastIdentitySql(PkColumn identityColumn)
identityColumn - the identity columnpublic boolean isPmdBroken()
protected void logRelaxed(SQLException e, String message)
e - the sql exceptionmessage - the messagepublic abstract boolean paginationNeedsMaxResultsAlways()
public abstract boolean paginationNeedsStartAlways()
protected String qualified(String schema, String jdbcClassName)
schema - the schema namejdbcClassName - the name of the table or sequenceSQLException - thrown in case of an SQL errorpublic abstract IdType supports(GenerationType type)
Copyright © 2012 Batoo Software & Consultancy. All Rights Reserved.