Package simpleorm.drivers
Class SDriverMSSQL
- java.lang.Object
-
- simpleorm.sessionjdbc.SDriver
-
- simpleorm.drivers.SDriverMSSQL
-
public class SDriverMSSQL extends SDriver
This contains MS SQL Server specific code.CHAR, VARCHAR max 8,000. TEXT 2^31. NVARCHAR/NCHAR UTF16, max size 4,000.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class simpleorm.sessionjdbc.SDriver
SDriver.OffsetStrategy
-
-
Constructor Summary
Constructors Constructor Description SDriverMSSQL()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
alterTableAddColumnSQL(SFieldScalar field)
These alow you to create a new SFieldMeta object at runtime and then update the table to include it.protected java.lang.String
columnTypeSQL(SFieldScalar field, java.lang.String defalt)
Apparently need DATETIME instead of TIMESTAMPprotected java.lang.String
driverName()
The driver name to be compared to getMetaData().getDriverName()protected java.lang.String
forUpdateSQL(boolean forUpdate)
Returns update clause, may not be valid in certain lock modes etc.boolean
getXLockEnabled()
protected java.lang.String
postFromSQL(boolean forUpdate)
It is unclear how MS SQL 2005 does snapshot locking -- very complex, needs experimentation.void
setXLockEnabled(boolean xlock)
Enables WITH (XLOCK) for updatable queries.-
Methods inherited from class simpleorm.sessionjdbc.SDriver
addNull, alterTableDropColumnSQL, appendColumnName, appendQuotedIdentifier, appendQuotedIdentifier, appendTableName, clauseSeparator, createSequenceDDL, createTableSQL, deleteSQL, dropSequenceDDL, dropTableNoError, foreignKeysSQL, fromSQL, generateKeySelectMax, generateKeySequence, getLogger, getOffsetStrategy, getSession, indexKeySQL, insertSQL, joinSQL, limitSQL, makeForeignKeyIndexSQL, mapForeignKeys, maxIdentNameLength, postColumnSQL, postTablePostParenSQL, postTablePreParenSQL, primaryKeySQL, queryExecuteFactory, registerDriver, selectSQL, selectSQL, supportsKeySequences, supportsLocking, updateSQL, whereSQL, wholeColumnSQL
-
-
-
-
Method Detail
-
driverName
protected java.lang.String driverName()
Description copied from class:SDriver
The driver name to be compared to getMetaData().getDriverName()- Overrides:
driverName
in classSDriver
-
columnTypeSQL
protected java.lang.String columnTypeSQL(SFieldScalar field, java.lang.String defalt)
Apparently need DATETIME instead of TIMESTAMP- Overrides:
columnTypeSQL
in classSDriver
-
forUpdateSQL
protected java.lang.String forUpdateSQL(boolean forUpdate)
Description copied from class:SDriver
Returns update clause, may not be valid in certain lock modes etc. Right at the end of the query.Oracle, Postgresql, and new in MS SQL 2005 support data versioning or snapshots. This means that repeatable read is achieved by caching the previous value read instead of using read locks. This approach makes it critical to add FOR UPDATE where appropriate or there is effectively no locking.
Indeed, in Oracle, you are guaranteed that several SELECTS will return the same value, but a subsequent SELECT FOR UPDATE in the same transaction may return a different value.
- Overrides:
forUpdateSQL
in classSDriver
-
postFromSQL
protected java.lang.String postFromSQL(boolean forUpdate)
It is unclear how MS SQL 2005 does snapshot locking -- very complex, needs experimentation. http://msdn.microsoft.com/en-us/library/ms345124.aspxNeed for XLOCK is unclear. However, Jorge says that it is unnecessary and makes SimpleORM fail, but it works for me.
- Overrides:
postFromSQL
in classSDriver
- See Also:
for discussion.
-
setXLockEnabled
public void setXLockEnabled(boolean xlock)
Enables WITH (XLOCK) for updatable queries. Should reduce deadlocks but apparantly can cause bugs. (Not supported in SQL 7? Something about HOLDLOCK?)
-
getXLockEnabled
public boolean getXLockEnabled()
-
alterTableAddColumnSQL
public java.lang.String alterTableAddColumnSQL(SFieldScalar field)
Description copied from class:SDriver
These alow you to create a new SFieldMeta object at runtime and then update the table to include it. Eg. for end user customizations. ## Ideally this could be further automated so that the SRecordMeta and JDBC meta data for a table could be compared and the table automatically altered.- Overrides:
alterTableAddColumnSQL
in classSDriver
-
-