org.rimudb.sql
Interface ISQLAdapter

All Known Implementing Classes:
DB2Adapter, DB2ISeriesAdapter, DefaultAdapter, DerbyAdapter, H2Adapter, HsqldbAdapter, MySQLAdapter, Oracle8iAdapter, Oracle9iAdapter, PostgreSQLAdapter, SQLServerAdapter

public interface ISQLAdapter

Author:
Simon Ritchie

Field Summary
static int IDENTITY_GENERATED_KEYS
           
static int IDENTITY_INSERT_STMT
           
static int IDENTITY_SEPARATE_STATEMENT
           
 
Method Summary
 java.lang.String build(java.lang.String selectClause, java.lang.String tableName, java.lang.String whereClause, java.lang.String groupByClause, java.lang.String orderByClause, int maxRecords)
           
 java.lang.String build(TableMetaData tableMetaData, java.lang.String tableName, WhereList whereList, GroupByList groupByList, OrderByList orderByList, int maxRecords, boolean useLockingHints)
           
 java.lang.String convertAutoIncrement(boolean autoIncrement)
          Return the String used for auto increment columns.
 java.lang.String convertNullCapable(boolean nullCapable, boolean isAutoIncrement)
          Return the String for null capability.
 java.lang.String convertSQLType(int type, long precision, int scale)
          Convert the SQL type to a type that the database can handle.
 void correctRecordData(TableMetaData tableMetaData, Record record)
          Transform record data that will not be able to be written to this database without some alteration.
 java.lang.String getBeginLimitClause(int maxRecords, int offset)
          Returns a clause that is used before the select statement (usually in conjunction with an end limit clause that limits the number of records returned to the first n records.
 char getCloseQuote()
          Return the database close quote character.
 java.lang.String getCreateIfExistsClause()
          Return the If Exists clause for a create table statement
 java.lang.String getCreateTableSQL(java.lang.String qualifiedTableName, TableMetaData tableMetaData, boolean ignoreIfExists, boolean prettyFormat)
          Return the create table SQL.
 RimuDBDatabaseMetaData getDatabaseMetaData()
          Return the RimuDBDatabaseMetaData.
 java.lang.String getDatabaseNames()
          Return a String containing an ordered list of database names.
 java.lang.String getDeleteStatement(TableMetaData tableMetaData, java.lang.String tableName, WhereList whereList)
          Return a parameterized delete statement that will remove records that match the column names on the KeyList and WhereList.
 java.lang.String getDropIfExistsClause()
          Return the clause for "drop if exists".
 java.lang.String getEndLimitClause(int maxRecords, int offset)
          Returns a clause for a select statement that limits the number of records returned to the first n records.
 java.lang.String getIdentitySelectSQL(java.lang.String tableName, java.lang.String autoIncrementColumn, int columnType)
          Return an SQL statement that will return the value assigned to an auto-increment column.
 java.lang.String getInsertStatement(TableMetaData tableMetaData, java.lang.String tableName)
          Return a parameterized insert statement.
 java.lang.String getLockingHint(LockHintType lockHintType)
          Return the locking hint for this database.
 char getOpenQuote()
          Return the database open quote character.
 java.lang.String getPrimaryKeySelectStatement(Lock lock, TableMetaData tableMetaData, java.lang.String tableName)
          Return an SQL statement to retrieve all the columns for the primary key.
 java.lang.String getPrimaryKeyUpdateStatement(TableMetaData tableMetaData, java.lang.String tableName, OptimisticLocking optimisticLocking, java.util.List<java.lang.String> changedPropertyList, java.util.List<java.lang.String> nullColumnList)
          Return an update statement that sets all the columns in a record for a given primary key.
 java.lang.String getSelectAllSQL(java.lang.String tableName)
          Return an SQL Statement that will select all the records in the table.
 java.lang.String getSelectCountSQL(TableMetaData tableMetaData, java.lang.String tableName, WhereList whereList)
           
 boolean getSupportsMultipleGetGeneratedKeys()
          Return true if this database supports returning a multiple row result set of generated keys
 boolean getSupportsReturnGeneratedKeys()
          Return true if the database supports the use of prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); If it doesn't then the method prepareStatement(sql, identityColumns[]); will be used.
 java.lang.String getTableType()
          Return the type of table for the CREATE TABLE clause.
 java.lang.String getTruncateTableSQL(java.lang.String tableName)
          Return an SQL Statement that will truncate the table.
 boolean hasPrimaryKeyClause()
          Return true if the Create Table statement should have a PRIMARY KEY clause
 boolean isInsertIndentityStatementSupported()
          Return true if the database supports a awy of extracting the identity value from the insert statement.
 void setDatabaseConfiguration(DatabaseConfiguration databaseConfiguration)
          Set the DatabaseConfiguration.
 void setDatabaseMetaData(RimuDBDatabaseMetaData dbMetaData)
          Set the RimuDBDatabaseMetaData.
 void setUseQuotes(boolean useQuotes)
          Set the useQuotes property.
 

Field Detail

IDENTITY_GENERATED_KEYS

static final int IDENTITY_GENERATED_KEYS
See Also:
Constant Field Values

IDENTITY_SEPARATE_STATEMENT

static final int IDENTITY_SEPARATE_STATEMENT
See Also:
Constant Field Values

IDENTITY_INSERT_STMT

static final int IDENTITY_INSERT_STMT
See Also:
Constant Field Values
Method Detail

build

java.lang.String build(TableMetaData tableMetaData,
                       java.lang.String tableName,
                       WhereList whereList,
                       GroupByList groupByList,
                       OrderByList orderByList,
                       int maxRecords,
                       boolean useLockingHints)
                       throws RimuDBException
Throws:
RimuDBException

build

java.lang.String build(java.lang.String selectClause,
                       java.lang.String tableName,
                       java.lang.String whereClause,
                       java.lang.String groupByClause,
                       java.lang.String orderByClause,
                       int maxRecords)
                       throws RimuDBException
Throws:
RimuDBException

convertSQLType

java.lang.String convertSQLType(int type,
                                long precision,
                                int scale)
Convert the SQL type to a type that the database can handle.

Parameters:
type - int
precision - long
scale - int
Returns:
String

convertNullCapable

java.lang.String convertNullCapable(boolean nullCapable,
                                    boolean isAutoIncrement)
Return the String for null capability.

Parameters:
nullCapable - boolean
isAutoIncrement - boolean
Returns:
String

getCreateIfExistsClause

java.lang.String getCreateIfExistsClause()
Return the If Exists clause for a create table statement

Returns:
String

getCreateTableSQL

java.lang.String getCreateTableSQL(java.lang.String qualifiedTableName,
                                   TableMetaData tableMetaData,
                                   boolean ignoreIfExists,
                                   boolean prettyFormat)
Return the create table SQL.

Parameters:
qualifiedTableName - String
tableMetaData - TableMetaData
ignoreIfExists - boolean
Returns:
String

getBeginLimitClause

java.lang.String getBeginLimitClause(int maxRecords,
                                     int offset)
Returns a clause that is used before the select statement (usually in conjunction with an end limit clause that limits the number of records returned to the first n records.

Parameters:
maxRecords - int
offset - int
Returns:
String

getEndLimitClause

java.lang.String getEndLimitClause(int maxRecords,
                                   int offset)
Returns a clause for a select statement that limits the number of records returned to the first n records.

Parameters:
maxRecords - int
offset - int
Returns:
String

hasPrimaryKeyClause

boolean hasPrimaryKeyClause()
Return true if the Create Table statement should have a PRIMARY KEY clause

Returns:
boolean

getTableType

java.lang.String getTableType()
Return the type of table for the CREATE TABLE clause.

Returns:
String

convertAutoIncrement

java.lang.String convertAutoIncrement(boolean autoIncrement)
Return the String used for auto increment columns.

Parameters:
autoIncrement - boolean
Returns:
String

getPrimaryKeySelectStatement

java.lang.String getPrimaryKeySelectStatement(Lock lock,
                                              TableMetaData tableMetaData,
                                              java.lang.String tableName)
Return an SQL statement to retrieve all the columns for the primary key.

Parameters:
lock - Lock
tableMetaData - TableMetaData
tableName - String
Returns:
String

getPrimaryKeyUpdateStatement

java.lang.String getPrimaryKeyUpdateStatement(TableMetaData tableMetaData,
                                              java.lang.String tableName,
                                              OptimisticLocking optimisticLocking,
                                              java.util.List<java.lang.String> changedPropertyList,
                                              java.util.List<java.lang.String> nullColumnList)
Return an update statement that sets all the columns in a record for a given primary key.

Parameters:
tableMetaData - TableMetaData
tableName - String
optimisticLocking - OptimisticLocking
changedPropertyList - List
nullColumnList - List
Returns:
String

getDeleteStatement

java.lang.String getDeleteStatement(TableMetaData tableMetaData,
                                    java.lang.String tableName,
                                    WhereList whereList)
                                    throws RimuDBException
Return a parameterized delete statement that will remove records that match the column names on the KeyList and WhereList.

Parameters:
tableMetaData - TableMetaData
tableName - String
whereList - WhereList
Returns:
String
Throws:
RimuDBException

getInsertStatement

java.lang.String getInsertStatement(TableMetaData tableMetaData,
                                    java.lang.String tableName)
Return a parameterized insert statement.

Parameters:
tableMetaData - TableMetaData
tableName - String
Returns:
String

getDatabaseNames

java.lang.String getDatabaseNames()
Return a String containing an ordered list of database names.

Returns:
String

isInsertIndentityStatementSupported

boolean isInsertIndentityStatementSupported()
Return true if the database supports a awy of extracting the identity value from the insert statement.


getIdentitySelectSQL

java.lang.String getIdentitySelectSQL(java.lang.String tableName,
                                      java.lang.String autoIncrementColumn,
                                      int columnType)
Return an SQL statement that will return the value assigned to an auto-increment column.

Parameters:
tableName - String
autoIncrementColumn - String
columnType - int
Returns:
String

setDatabaseConfiguration

void setDatabaseConfiguration(DatabaseConfiguration databaseConfiguration)
Set the DatabaseConfiguration.

Parameters:
databaseConfiguration - DatabaseConfiguration

setDatabaseMetaData

void setDatabaseMetaData(RimuDBDatabaseMetaData dbMetaData)
Set the RimuDBDatabaseMetaData.

Parameters:
dbMetaData - RimuDBDatabaseMetaData

getDatabaseMetaData

RimuDBDatabaseMetaData getDatabaseMetaData()
Return the RimuDBDatabaseMetaData.

Returns:
RimuDBDatabaseMetaData

getSelectCountSQL

java.lang.String getSelectCountSQL(TableMetaData tableMetaData,
                                   java.lang.String tableName,
                                   WhereList whereList)
                                   throws RimuDBException
Parameters:
tableMetaData - TableMetaData
tableName - String
whereList - WhereList
Returns:
String
Throws:
RimuDBException

getDropIfExistsClause

java.lang.String getDropIfExistsClause()
Return the clause for "drop if exists".

Returns:
String

getOpenQuote

char getOpenQuote()
Return the database open quote character.

Returns:
char

getCloseQuote

char getCloseQuote()
Return the database close quote character.

Returns:
char

setUseQuotes

void setUseQuotes(boolean useQuotes)
Set the useQuotes property.

Parameters:
useQuotes - boolean

getSupportsReturnGeneratedKeys

boolean getSupportsReturnGeneratedKeys()
Return true if the database supports the use of prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); If it doesn't then the method prepareStatement(sql, identityColumns[]); will be used.

Returns:
boolean

getSupportsMultipleGetGeneratedKeys

boolean getSupportsMultipleGetGeneratedKeys()
Return true if this database supports returning a multiple row result set of generated keys

Returns:
boolean

getLockingHint

java.lang.String getLockingHint(LockHintType lockHintType)
Return the locking hint for this database.

Parameters:
lockHintType - LockHintType
Returns:
String

getSelectAllSQL

java.lang.String getSelectAllSQL(java.lang.String tableName)
Return an SQL Statement that will select all the records in the table.

Parameters:
tableName -
Returns:
String

getTruncateTableSQL

java.lang.String getTruncateTableSQL(java.lang.String tableName)
Return an SQL Statement that will truncate the table.

Parameters:
tableName -
Returns:
String

correctRecordData

void correctRecordData(TableMetaData tableMetaData,
                       Record record)
                       throws RimuDBException
Transform record data that will not be able to be written to this database without some alteration. This is used when copying a table from one database to another. Sometimes column values that are permissible in the source database are not permissible in the target database. This method allows the values of the target database to alter the values prior to being written.

Parameters:
tableMetaData - TableMetaData
record - Record
Throws:
RimuDBException


Copyright © 2008-2011 Simon Ritchie. All Rights Reserved.