primaryKeySQL
PRIMARY KEY(KCOL, KCOL)
appended to end.SDriverDB2
, SDriverDerby
, SDriverHSQLH2
, SDriverInformix
, SDriverInterbase
, SDriverMSSQL
, SDriverMySQL
, SDriverOracle
, SDriverPostgres
, SDriverSapDB
, SDriverSybase
, SQLiteDriver
(Profiling suggests that memoising these generaters could produce a 5-10% improvement in bulk updates.)
There is now one driver instance per connection so one can say SSession.getDriver().setMyFavouriteParam(...)
SQL 92 standard data types, I think:- boolean, Character(n), character varying(n), date, float(p), real, double precission, smallint, int | integer, decimal(p,s), numeric(p,s), time, interval, timestamp with timezone,
protected void
addNull(StringBuffer sql,
SFieldScalar fld)
void
appendColumnName(SFieldScalar field,
StringBuffer buf)
protected void
appendQuotedIdentifier(String ident,
StringBuffer buf)
protected void
appendQuotedIdentifier(String ident,
StringBuffer buf,
char quote)
void
appendTableName(SRecordMeta table,
StringBuffer buf)
protected String
clauseSeparator(String indent)
protected String
columnTypeSQL(SFieldScalar field,
String defalt)
protected String
createSequenceDDL(String name)
createTableSQL(SRecordMeta<?> meta)
CREATE TABLE
for this table.protected String
deleteSQL(SRecordMeta from,
ArrayList where,
SRecordInstance instance,
Object[] keyMetaValues)
protected String
protected String
dropSequenceDDL(String name)
void
dropTableNoError(String table)
protected String
foreignKeysSQL(SRecordMeta meta)
FOREIGN KEY (FKCOL, FKCOL) REFERENCES FTABLE (KCOL,
KCOL)
appended to end.protected String
forUpdateSQL(boolean forUpdate)
protected void
fromSQL(SRecordMeta from,
SRecordMeta[] joinTables,
StringBuffer res)
protected long
generateKeySelectMax(SRecordMeta rec,
SFieldScalar keyFld)
protected long
generateKeySequence(SRecordMeta<?> rec,
SFieldScalar keyFld)
protected SDriver.OffsetStrategy
protected String
indexKeySQL(SRecordMeta meta)
protected String
insertSQL(ArrayList<SFieldScalar> updates,
SRecordMeta from)
protected String
joinSQL(SRecordMeta[] joinTables)
protected String
limitSQL(long offset,
long limit)
protected void
makeForeignKeyIndexSQL(SRecordMeta meta,
int fx,
SFieldReference fldRef,
StringBuffer sbFkey,
StringBuffer sbRefed,
StringBuffer fkey)
protected String
mapForeignKeys(SRecordMeta<?> meta,
boolean foreignKey)
int
protected String
postColumnSQL(SFieldMeta field)
protected String
postFromSQL(boolean forUpdate)
protected String
protected String
protected String
primaryKeySQL(SRecordMeta<?> meta)
PRIMARY KEY(KCOL, KCOL)
appended to end.protected simpleorm.sessionjdbc.SQueryExecute
queryExecuteFactory(SSessionJdbc session,
SQuery query)
void
protected String
selectSQL(SFieldScalar[] select,
SRecordMeta<?> from,
String join,
String where,
String orderBy,
boolean forUpdate,
simpleorm.sessionjdbc.SQueryExecute sps)
protected String
selectSQL(SFieldScalar[] select,
SRecordMeta from,
SFieldScalar[] where,
String orderBy,
boolean forUpdate,
simpleorm.sessionjdbc.SQueryExecute sps)
boolean
boolean
protected String
updateSQL(ArrayList<SFieldScalar> updates,
SRecordMeta from,
ArrayList<SFieldScalar> where,
SRecordInstance instance,
Object[] keyMetaValues)
protected void
whereSQL(StringBuffer ret,
ArrayList<SFieldScalar> where,
SRecordInstance instance,
Object[] keyMetaValues)
protected String
MY_COL VARCHAR(13) NOT NULL
.CREATE TABLE
for this table. Delegated from
SRecord. This is split up into many sub-methods so that they can be
selectively specialized by other drivers.MY_COL VARCHAR(13) NOT NULL
.#SMANDATORY
PRIMARY KEY(KCOL, KCOL)
appended to end.FOREIGN KEY (FKCOL, FKCOL) REFERENCES FTABLE (KCOL,
KCOL)
appended to end.select
and where
are arrays
of SFieldMeta
s. Returns SQL statement as a string.
This now quotes table and column names so that they become case independent.
sps is links to the SPreparedStatement object. It can have arbitrary properties set to provide fine control over the query. Examples include limits.
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.
offset
- number of rows to skiplimit
- number of rows to retrieveupdates
and where
are SSArrayLists
of SFieldMetas. Returns SQL statement as a string.updates
and where
are SSArrayLists
of SFieldMetas. Returns SQL statement as a string.where
are SSArrayLists of SFieldMetas. Returns
SQL statement as a string.Defaults to BULK
## (There is scope to optimize this at some point so that one JDBC call can both generate the sequence number and insert a new record. But that means that the new record's key is not available until insert time which causes problems for foreign keys. Alternatively one can get batches of 10 (say) sequences at a time and then use an internal counter, but this will leave big holes in the sequence. Defer this to version 1.)