org.eclipse.persistence.platform.database
Class SQLServerPlatform

java.lang.Object
  extended by org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform
      extended by org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
          extended by org.eclipse.persistence.platform.database.DatabasePlatform
              extended by org.eclipse.persistence.platform.database.SQLServerPlatform
All Implemented Interfaces:
Serializable, Cloneable, org.eclipse.persistence.internal.databaseaccess.Platform

public class SQLServerPlatform
extends DatabasePlatform

Purpose: Provides SQL Server specific behavior.

Responsibilities:

Since:
TOPLink/Java 1.0
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.eclipse.persistence.platform.database.DatabasePlatform
DEFAULT_VARCHAR_SIZE
 
Fields inherited from class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
DEFAULT_MAX_BATCH_WRITING_SIZE, DEFAULT_PARAMETERIZED_MAX_BATCH_WRITING_SIZE, Types_NCLOB
 
Constructor Summary
SQLServerPlatform()
           
 
Method Summary
 ValueReadQuery buildSelectQueryForIdentity()
          INTERNAL: Build the identity query for native sequencing.
 boolean dontBindUpdateAllQueryUsingTempTables()
          INTERNAL: In SQLServer local temporary table created by one PreparedStatement can't be used in another PreparedStatement.
 Object executeStoredProcedure(org.eclipse.persistence.internal.databaseaccess.DatabaseCall dbCall, PreparedStatement statement, org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor accessor, org.eclipse.persistence.internal.sessions.AbstractSession session)
          because each platform has different requirements for accessing stored procedures and the way that we can combine resultsets and output params the stored procedure call is being executed on the platform.
 String getBatchDelimiterString()
          Used for batch writing and sp defs.
 String getCreationInOutputProcedureToken()
          This method is used to print the required output parameter token for the specific platform.
 String getCreationOutputProcedureToken()
          This method is used to print the required output parameter token for the specific platform.
 String getInOutputProcedureToken()
          This method is used to print the output parameter token when stored procedures are called
 int getMaxFieldNameSize()
          INTERNAL: returns the maximum number of characters that can be used in a field name on this platform.
 Vector getNativeTableInfo(String table, String creator, org.eclipse.persistence.internal.sessions.AbstractSession session)
          Return the catalog information through using the native SQL catalog selects.
 String getOutputProcedureToken()
          This method is used to print the output parameter token when stored procedures are called
 String getProcedureArgumentString()
          Used for sp defs.
 String getProcedureCallHeader()
          Used for sp calls.
 String getSelectForUpdateNoWaitString()
          INTERNAL: This syntax does no wait on the lock.
 String getSelectForUpdateString()
          INTERNAL: Lock.
 String getStoredProcedureParameterPrefix()
           
 String getStoredProcedureTerminationToken()
          INTERNAL: This method returns the delimiter between stored procedures in multiple stored procedure calls.
 org.eclipse.persistence.internal.helper.DatabaseTable getTempTableForTable(org.eclipse.persistence.internal.helper.DatabaseTable table)
          INTERNAL:
 ValueReadQuery getTimestampQuery()
          PUBLIC: This method returns the query to select the timestamp from the server for SQLServer.
 boolean isSQLServer()
           
static ExpressionOperator locate2Operator()
          INTERNAL: create the Locate2 Operator for this platform
 Hashtable maximumNumericValues()
          Builds a table of maximum numeric values keyed on java class.
 Hashtable minimumNumericValues()
          Builds a table of minimum numeric values keyed on java class.
 ExpressionOperator modOperator()
          Override the default MOD operator.
 void printFieldIdentityClause(Writer writer)
          INTERNAL: Append the receiver's field 'identity' constraint clause to a writer.
 void printFieldNullClause(Writer writer)
          INTERNAL: Append the receiver's field 'NULL' constraint clause to a writer.
 boolean requiresProcedureCallBrackets()
          USed for sp calls.
 boolean requiresProcedureCallOuputToken()
          Used for sp calls.
 boolean shouldPrintInOutputTokenBeforeType()
          This is required in the construction of the stored procedures with output parameters
 boolean shouldPrintLockingClauseAfterWhereClause()
          INTERNAL: Indicates whether locking clause should be printed after where clause by SQLSelectStatement.
 boolean shouldPrintOutputTokenBeforeType()
          This is required in the construction of the stored procedures with output parameters
 boolean shouldUseJDBCOuterJoinSyntax()
          JDBC defines and outer join syntax, many drivers do not support this.
 ExpressionOperator singleArgumentSubstringOperator()
          Override the default SubstringSingleArg operator.
 boolean supportsIdentity()
          INTERNAL: Indicates whether the platform supports identity.
 boolean supportsLocalTempTables()
          INTERNAL:
 void writeUpdateOriginalFromTempTableSql(Writer writer, org.eclipse.persistence.internal.helper.DatabaseTable table, Collection pkFields, Collection assignedFields)
          INTERNAL:
 
Methods inherited from class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
addBatch, addStructConverter, allowsSizeInProcedureArguments, appendLiteralToCall, appendParameter, appendParameterInternal, autoCommit, beginTransaction, buildCallWithReturning, buildCreateIndex, buildDropIndex, buildProcedureCallString, buildSelectQueryForIdentity, buildSelectQueryForSequenceObject, buildSelectQueryForSequenceObject, buildSequenceObjectAlterIncrementWriter, buildSequenceObjectCreationWriter, buildSequenceObjectDeletionWriter, canBatchWriteWithOptimisticLocking, canBuildCallWithReturning, commitTransaction, computeMaxRowsForSQL, convertToDatabaseType, copyInto, createArray, createArray, createStruct, createStruct, executeBatch, freeTemporaryObject, getAssignmentString, getBatchBeginString, getBatchEndString, getCastSizeForVarcharParameter, getClassTypes, getConnection, getConstraintDeletionString, getCreateViewString, getCursorCode, getCustomModifyValueForCall, getDefaultSequenceTableName, getFieldTypeDefinition, getFieldTypes, getFunctionCallHeader, getIdentifierQuoteCharacter, getInputProcedureToken, getJDBCOuterJoinString, getJDBCType, getJDBCType, getJdbcTypeName, getMaxBatchWritingSize, getMaxForeignKeyNameSize, getMaxIndexNameSize, getMaxUniqueKeyNameSize, getNoWaitString, getObjectFromResultSet, getPingSQL, getProcedureArgumentSetter, getProcedureAsString, getProcedureBeginString, getProcedureCallTail, getProcedureEndString, getQualifiedName, getQualifiedSequenceTableName, getRefValue, getRefValue, getSelectForUpdateOfString, getSelectForUpdateWaitString, getSequenceCounterFieldName, getSequenceNameFieldName, getSequencePreallocationSize, getSequenceTableName, getStatementCacheSize, getStringBindingSize, getStructConverters, getTransactionIsolation, getTypeConverters, initialize, isAlterSequenceObjectSupported, isCastRequired, isDynamicSQLRequiredForFunctions, isForUpdateCompatibleWithDistinct, isInformixOuterJoin, isLockTimeoutException, isNullAllowedInSelectClause, isXDBDocument, prepareBatchStatement, printFieldNotNullClause, printFieldTypeSize, printFieldUnique, printSQLSelectStatement, printValuelist, printValuelist, registerOutputParameter, requiresNamedPrimaryKeyConstraints, requiresProcedureBrackets, requiresTypeNameToRegisterOutputParameter, requiresUniqueConstraintCreationOnTableCreate, rollbackTransaction, setCastSizeForVarcharParameter, setCursorCode, setIsCastRequired, setMaxBatchWritingSize, setParameterValueInDatabaseCall, setPingSQL, setPrintOuterJoinInWhereClause, setSequenceCounterFieldName, setSequenceNameFieldName, setSequenceTableName, setShouldBindAllParameters, setShouldBindLiterals, setShouldCacheAllStatements, setShouldForceFieldNamesToUpperCase, setShouldIgnoreCaseOnFieldComparisons, setShouldOptimizeDataConversion, setShouldTrimStrings, setShouldUseRownumFiltering, setStatementCacheSize, setStringBindingSize, setSupportsAutoCommit, setTransactionIsolation, setUsesBatchWriting, setUsesByteArrayBinding, setUsesJDBCBatchWriting, setUsesNativeBatchWriting, setUsesNativeSQL, setUsesStreamsForBinding, setUsesStringBinding, shouldAlwaysUseTempStorageForModifyAll, shouldBindAllParameters, shouldBindLiterals, shouldCacheAllStatements, shouldCreateIndicesForPrimaryKeys, shouldCreateIndicesOnUniqueKeys, shouldForceFieldNamesToUpperCase, shouldIgnoreCaseOnFieldComparisons, shouldIgnoreException, shouldNativeSequenceUseTransaction, shouldOptimizeDataConversion, shouldPrintAliasForUpdate, shouldPrintConstraintNameAfter, shouldPrintFieldIdentityClause, shouldPrintInputTokenAtStart, shouldPrintOuterJoinInWhereClause, shouldPrintOutputTokenAtStart, shouldPrintStoredProcedureArgumentNameInCall, shouldPrintStoredProcedureVariablesAfterBeginString, shouldTrimStrings, shouldUseCustomModifyForCall, shouldUseRownumFiltering, supportsANSIInnerJoinSyntax, supportsAutoCommit, supportsAutoConversionToNumericForArithmeticOperations, supportsForeignKeyConstraints, supportsGlobalTempTables, supportsIndividualTableLocking, supportsLockingQueriesWithMultipleTables, supportsNativeSequenceNumbers, supportsNestingOuterJoins, supportsOuterJoinsWithBrackets, supportsPrimaryKeyConstraint, supportsSequenceObjects, supportsStoredFunctions, supportsTempTables, supportsUniqueColumns, supportsUniqueKeyConstraints, usesBatchWriting, usesByteArrayBinding, usesJDBCBatchWriting, usesNativeBatchWriting, usesNativeSQL, usesSequenceTable, usesStreamsForBinding, usesStringBinding, wasFailureCommunicationBased, writeCleanUpTempTableSql, writeCreateTempTableSql, writeDeleteFromTargetTableUsingTempTableSql, writeInsertIntoTableSql, writeLOB, writeParameterMarker
 
Methods inherited from class org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform
addSequence, clone, convertObject, createConnectionCustomizer, getConversionManager, getDataTypesConvertedFrom, getDataTypesConvertedTo, getDefaultSequence, getDefaultSequenceToWrite, getEndDelimiter, getOperator, getPlatformOperators, getSelectSequenceQuery, getSequence, getSequences, getSequencesToWrite, getStartDelimiter, getTableQualifier, getTimestampFromServer, getUpdateSequenceQuery, hasDefaultSequence, isAccess, isAttunity, isCloudscape, isDB2, isDBase, isDerby, isFirebird, isH2, isHSQL, isInformix, isMySQL, isODBC, isOracle, isOracle9, isPointBase, isPostgreSQL, isSQLAnywhere, isSybase, isSymfoware, isTimesTen, isTimesTen7, removeAllSequences, removeSequence, setConversionManager, setDefaultSequence, setEndDelimiter, setSelectSequenceNumberQuery, setSequencePreallocationSize, setSequences, setStartDelimiter, setTableQualifier, setTimestampQuery, setUpdateSequenceQuery, toString, usesPlatformDefaultSequence
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SQLServerPlatform

public SQLServerPlatform()
Method Detail

buildSelectQueryForIdentity

public ValueReadQuery buildSelectQueryForIdentity()
INTERNAL: Build the identity query for native sequencing.

Overrides:
buildSelectQueryForIdentity in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

dontBindUpdateAllQueryUsingTempTables

public boolean dontBindUpdateAllQueryUsingTempTables()
INTERNAL: In SQLServer local temporary table created by one PreparedStatement can't be used in another PreparedStatement. Workaround is to use Statement instead of PreparedStatement.

Overrides:
dontBindUpdateAllQueryUsingTempTables in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

getBatchDelimiterString

public String getBatchDelimiterString()
Used for batch writing and sp defs.

Overrides:
getBatchDelimiterString in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

getCreationInOutputProcedureToken

public String getCreationInOutputProcedureToken()
This method is used to print the required output parameter token for the specific platform. Used when stored procedures are created.

Overrides:
getCreationInOutputProcedureToken in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

getCreationOutputProcedureToken

public String getCreationOutputProcedureToken()
This method is used to print the required output parameter token for the specific platform. Used when stored procedures are created.

Overrides:
getCreationOutputProcedureToken in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

getInOutputProcedureToken

public String getInOutputProcedureToken()
This method is used to print the output parameter token when stored procedures are called

Overrides:
getInOutputProcedureToken in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

getMaxFieldNameSize

public int getMaxFieldNameSize()
INTERNAL: returns the maximum number of characters that can be used in a field name on this platform.

Overrides:
getMaxFieldNameSize in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

getNativeTableInfo

public Vector getNativeTableInfo(String table,
                                 String creator,
                                 org.eclipse.persistence.internal.sessions.AbstractSession session)
Return the catalog information through using the native SQL catalog selects. This is required because many JDBC driver do not support meta-data. Willcards can be passed as arguments.


getOutputProcedureToken

public String getOutputProcedureToken()
This method is used to print the output parameter token when stored procedures are called

Overrides:
getOutputProcedureToken in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

getProcedureArgumentString

public String getProcedureArgumentString()
Used for sp defs.

Overrides:
getProcedureArgumentString in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

getProcedureCallHeader

public String getProcedureCallHeader()
Used for sp calls.

Overrides:
getProcedureCallHeader in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

getStoredProcedureParameterPrefix

public String getStoredProcedureParameterPrefix()
Overrides:
getStoredProcedureParameterPrefix in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

getStoredProcedureTerminationToken

public String getStoredProcedureTerminationToken()
INTERNAL: This method returns the delimiter between stored procedures in multiple stored procedure calls.

Overrides:
getStoredProcedureTerminationToken in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

getTimestampQuery

public ValueReadQuery getTimestampQuery()
PUBLIC: This method returns the query to select the timestamp from the server for SQLServer.

Specified by:
getTimestampQuery in interface org.eclipse.persistence.internal.databaseaccess.Platform
Overrides:
getTimestampQuery in class org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform

getSelectForUpdateString

public String getSelectForUpdateString()
INTERNAL: Lock. UPDLOCK seems like the correct table hint to use: HOLDLOCK is too weak - doesn't lock out another read with HOLDLOCK, XLOCK is too strong - locks out another read which doesn't use any locks. UPDLOCK seems to behave exactly like Oracle's FOR UPDATE: locking out updates and other reads with FOR UPDATE but allowing other reads without locks. SQLServer seems to decide itself on the granularity of the lock - it could lock more than the returned rows (for instance a page). It could be forced to obtain to make sure to obtain row level lock: WITH (UPDLOCK, ROWLOCK) However this approach is strongly discouraged because it can consume too much resources: selecting 900 rows from and requiring a "personal" lock for each row may not be feasible because of not enough memory available at the moment - in that case SQLServer will wait until the resource becomes available.

Overrides:
getSelectForUpdateString in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

getSelectForUpdateNoWaitString

public String getSelectForUpdateNoWaitString()
INTERNAL: This syntax does no wait on the lock.

Overrides:
getSelectForUpdateNoWaitString in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

executeStoredProcedure

public Object executeStoredProcedure(org.eclipse.persistence.internal.databaseaccess.DatabaseCall dbCall,
                                     PreparedStatement statement,
                                     org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor accessor,
                                     org.eclipse.persistence.internal.sessions.AbstractSession session)
                              throws SQLException
because each platform has different requirements for accessing stored procedures and the way that we can combine resultsets and output params the stored procedure call is being executed on the platform. This entire process needs some serious refactoring to eliminate the chance of bugs.

Overrides:
executeStoredProcedure in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
Throws:
SQLException

shouldPrintLockingClauseAfterWhereClause

public boolean shouldPrintLockingClauseAfterWhereClause()
INTERNAL: Indicates whether locking clause should be printed after where clause by SQLSelectStatement. Example: on Oracle platform (method returns true): SELECT ADDRESS_ID, ... FROM ADDRESS WHERE (ADDRESS_ID = ?) FOR UPDATE on SQLServer platform (method returns false): SELECT ADDRESS_ID, ... FROM ADDRESS WITH (UPDLOCK) WHERE (ADDRESS_ID = ?)

Overrides:
shouldPrintLockingClauseAfterWhereClause in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

isSQLServer

public boolean isSQLServer()
Specified by:
isSQLServer in interface org.eclipse.persistence.internal.databaseaccess.Platform
Overrides:
isSQLServer in class org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform

maximumNumericValues

public Hashtable maximumNumericValues()
Builds a table of maximum numeric values keyed on java class. This is used for type testing but might also be useful to end users attempting to sanitize values.

NOTE: BigInteger & BigDecimal maximums are dependent upon their precision & Scale

Overrides:
maximumNumericValues in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

minimumNumericValues

public Hashtable minimumNumericValues()
Builds a table of minimum numeric values keyed on java class. This is used for type testing but might also be useful to end users attempting to sanitize values.

NOTE: BigInteger & BigDecimal minimums are dependent upon their precision & Scale

Overrides:
minimumNumericValues in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

modOperator

public ExpressionOperator modOperator()
Override the default MOD operator.


singleArgumentSubstringOperator

public ExpressionOperator singleArgumentSubstringOperator()
Override the default SubstringSingleArg operator.


locate2Operator

public static ExpressionOperator locate2Operator()
INTERNAL: create the Locate2 Operator for this platform


printFieldIdentityClause

public void printFieldIdentityClause(Writer writer)
                              throws ValidationException
INTERNAL: Append the receiver's field 'identity' constraint clause to a writer.

Overrides:
printFieldIdentityClause in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
Throws:
ValidationException

printFieldNullClause

public void printFieldNullClause(Writer writer)
                          throws ValidationException
INTERNAL: Append the receiver's field 'NULL' constraint clause to a writer.

Overrides:
printFieldNullClause in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
Throws:
ValidationException

requiresProcedureCallBrackets

public boolean requiresProcedureCallBrackets()
USed for sp calls.

Overrides:
requiresProcedureCallBrackets in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

requiresProcedureCallOuputToken

public boolean requiresProcedureCallOuputToken()
Used for sp calls. Sybase must print output after output params.

Overrides:
requiresProcedureCallOuputToken in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

shouldPrintInOutputTokenBeforeType

public boolean shouldPrintInOutputTokenBeforeType()
This is required in the construction of the stored procedures with output parameters

Overrides:
shouldPrintInOutputTokenBeforeType in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

shouldPrintOutputTokenBeforeType

public boolean shouldPrintOutputTokenBeforeType()
This is required in the construction of the stored procedures with output parameters

Overrides:
shouldPrintOutputTokenBeforeType in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

shouldUseJDBCOuterJoinSyntax

public boolean shouldUseJDBCOuterJoinSyntax()
JDBC defines and outer join syntax, many drivers do not support this. So we normally avoid it.

Overrides:
shouldUseJDBCOuterJoinSyntax in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

supportsIdentity

public boolean supportsIdentity()
INTERNAL: Indicates whether the platform supports identity. SQLServer does through IDENTITY field types. This method is to be used *ONLY* by sequencing classes

Overrides:
supportsIdentity in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

supportsLocalTempTables

public boolean supportsLocalTempTables()
INTERNAL:

Overrides:
supportsLocalTempTables in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform

getTempTableForTable

public org.eclipse.persistence.internal.helper.DatabaseTable getTempTableForTable(org.eclipse.persistence.internal.helper.DatabaseTable table)
INTERNAL:

Overrides:
getTempTableForTable in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
Returns:
DatabaseTable temorary table

writeUpdateOriginalFromTempTableSql

public void writeUpdateOriginalFromTempTableSql(Writer writer,
                                                org.eclipse.persistence.internal.helper.DatabaseTable table,
                                                Collection pkFields,
                                                Collection assignedFields)
                                         throws IOException
INTERNAL:

Overrides:
writeUpdateOriginalFromTempTableSql in class org.eclipse.persistence.internal.databaseaccess.DatabasePlatform
Throws:
IOException