org.rimudb.sql
Class SQLServerAdapter

java.lang.Object
  extended by org.rimudb.sql.DefaultAdapter
      extended by org.rimudb.sql.SQLServerAdapter
All Implemented Interfaces:
ISQLAdapter

public class SQLServerAdapter
extends DefaultAdapter


Field Summary
 
Fields inherited from class org.rimudb.sql.DefaultAdapter
DB_H2, DB_HSQLDB, DB_ISERIES, DB_MYSQL, DB_SQLSERVER, DB_UNKNOWN, IDX_INDEX, IDX_PRIMARY, IDX_UNIQUE, LOCK_DELETE, LOCK_INSERT, LOCK_NONE, LOCK_SELECT, LOCK_UPDATE
 
Fields inherited from interface org.rimudb.sql.ISQLAdapter
IDENTITY_GENERATED_KEYS, IDENTITY_INSERT_STMT, IDENTITY_SEPARATE_STATEMENT
 
Constructor Summary
SQLServerAdapter()
           
 
Method Summary
 java.lang.String build(TableMetaData tableMetaData, java.lang.String tableName, WhereList whereList, GroupByList groupByList, OrderByList orderByList, int maxRecords, boolean useLockingHints)
          Build the SQL statement from a KeyList and a WhereList
 java.lang.String convertAutoIncrement(boolean autoIncrement)
          Return the auto increment string.
 java.lang.String convertSQLType(int type, long precision, int scale)
          Convert the SQL type to a textual representation.
 char getCloseQuote()
          Return the database close quote character.
 java.lang.String getCreateIfExistsClause()
          Return a the create table 'IF EXISTS' clause.
 java.lang.String getDropIfExistsClause()
          Return a the drop table 'IF EXISTS' clause.
 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 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> nulledPropertyList)
          Return an update statement that sets all the columns in a record for a given primary key.
 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.
 
Methods inherited from class org.rimudb.sql.DefaultAdapter
build, buildGroupByClause, buildOrderByClause, buildSelectClause, buildSQL, buildSQL, buildSQL, buildWhereClause, convertNullCapable, correctRecordData, getBeginLimitClause, getCreateTableSQL, getDatabaseConfiguration, getDatabaseMetaData, getDatabaseNames, getDeleteStatement, getDropTableSQL, getIdentitySelectSQL, getQuoter, getSelectAllSQL, getSelectCountSQL, getTableType, getTruncateTableSQL, hasPrimaryKeyClause, isInsertIndentityStatementSupported, setDatabaseConfiguration, setDatabaseMetaData, setUseQuotes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLServerAdapter

public SQLServerAdapter()
Method Detail

convertSQLType

public java.lang.String convertSQLType(int type,
                                       long precision,
                                       int scale)
Convert the SQL type to a textual representation.

Specified by:
convertSQLType in interface ISQLAdapter
Overrides:
convertSQLType in class DefaultAdapter
Parameters:
type - int
precision - long
scale - int
Returns:
String

build

public java.lang.String build(TableMetaData tableMetaData,
                              java.lang.String tableName,
                              WhereList whereList,
                              GroupByList groupByList,
                              OrderByList orderByList,
                              int maxRecords,
                              boolean useLockingHints)
                       throws RimuDBException
Build the SQL statement from a KeyList and a WhereList

Specified by:
build in interface ISQLAdapter
Overrides:
build in class DefaultAdapter
Returns:
String
Throws:
RimuDBException

convertAutoIncrement

public java.lang.String convertAutoIncrement(boolean autoIncrement)
Return the auto increment string.

Parameters:
autoIncrement - boolean
Returns:
String

getLockingHint

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

Specified by:
getLockingHint in interface ISQLAdapter
Overrides:
getLockingHint in class DefaultAdapter
Parameters:
lockHintType - LockHintType
Returns:
String

getPrimaryKeySelectStatement

public 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. This method overrides the default because MS SQL can have lock hints.

Specified by:
getPrimaryKeySelectStatement in interface ISQLAdapter
Overrides:
getPrimaryKeySelectStatement in class DefaultAdapter
Parameters:
lock - Lock
tableMetaData - TableMetaData
tableName - String
Returns:
String

getPrimaryKeyUpdateStatement

public 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> nulledPropertyList)
Return an update statement that sets all the columns in a record for a given primary key.

Specified by:
getPrimaryKeyUpdateStatement in interface ISQLAdapter
Overrides:
getPrimaryKeyUpdateStatement in class DefaultAdapter
Parameters:
tableMetaData - TableMetaData
tableName - String
optimisticLocking - OptimisticLocking
changedPropertyList - List
nulledPropertyList - List
Returns:
String

getInsertStatement

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

Specified by:
getInsertStatement in interface ISQLAdapter
Overrides:
getInsertStatement in class DefaultAdapter
Parameters:
tableMetaData - TableMetaData
tableName - String
Returns:
String

getCreateIfExistsClause

public java.lang.String getCreateIfExistsClause()
Return a the create table 'IF EXISTS' clause. Not supported for SQL Server.

Specified by:
getCreateIfExistsClause in interface ISQLAdapter
Specified by:
getCreateIfExistsClause in class DefaultAdapter
Returns:
String

getDropIfExistsClause

public java.lang.String getDropIfExistsClause()
Return a the drop table 'IF EXISTS' clause. Not supported for SQL Server.

Specified by:
getDropIfExistsClause in interface ISQLAdapter
Specified by:
getDropIfExistsClause in class DefaultAdapter
Returns:
String

getEndLimitClause

public 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

getOpenQuote

public char getOpenQuote()
Description copied from interface: ISQLAdapter
Return the database open quote character.

Specified by:
getOpenQuote in interface ISQLAdapter
Overrides:
getOpenQuote in class DefaultAdapter
Returns:
char

getCloseQuote

public char getCloseQuote()
Description copied from interface: ISQLAdapter
Return the database close quote character.

Specified by:
getCloseQuote in interface ISQLAdapter
Overrides:
getCloseQuote in class DefaultAdapter
Returns:
char

getSupportsReturnGeneratedKeys

public boolean getSupportsReturnGeneratedKeys()
Description copied from interface: ISQLAdapter
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

public boolean getSupportsMultipleGetGeneratedKeys()
Description copied from interface: ISQLAdapter
Return true if this database supports returning a multiple row result set of generated keys

Returns:
boolean


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