com.sag.osami.contextstore.storage.jdbc
Class GenericJDBCDialect

java.lang.Object
  extended by com.sag.osami.contextstore.storage.jdbc.GenericJDBCDialect
All Implemented Interfaces:
DBConstants, IJDBCDialect
Direct Known Subclasses:
DerbyDialect, MysqlDialect, PostgresqlDialect, SqliteDialect

public abstract class GenericJDBCDialect
extends java.lang.Object
implements IJDBCDialect

A basic implementation of a JDBC dialect, using only standard SQL.

However, as column type naming and behavior is often very database-specific, this aspect is left to actual dialect implementations. In particular, IJDBCDialect.createTable() remains unimplemented, but the convenience method createTable(String[]) is provided.

Naturally, IJDBCDialect.driver() also remains unimplemented.

See Also:
JDBCStorage, IJDBCDialect

Field Summary
 
Fields inherited from interface com.sag.osami.contextstore.storage.DBConstants
COL_CTXSTORE_ID, COL_DATA, COL_DATA_CLASS, COL_ID, COL_ORIGINID, COL_TIMESTAMP, COL_TYPE, COLS, TABLE_AND_COLS, TABLE_NAME
 
Constructor Summary
GenericJDBCDialect()
           
 
Method Summary
protected  java.lang.String createTable(java.lang.String[] colTypes)
          Returns a basic CREATE TABLE statement, using the DBConstants.TABLE_AND_COLS list for the table and column names and the colTypes parameter for the column types.
 java.lang.String deleteContextEvent()
          Returns the SQL statement for deleting a context event.
 java.lang.String dropTable()
          Returns the SQL statement for dropping the context store table.
protected static java.lang.String idParams(int idsCount)
          Convenience method for generating a (?
 java.lang.String insertContextEvent()
          Returns the SQL statement for inserting a context event.
 java.lang.String loadContextEvent()
          Returns the SQL statement for loading a context event.
 java.lang.String loadContextEvents(int idsCount)
          Returns the SQL statement for loading several context events.
 java.lang.String queryLastID()
          Returns the SQL statement for querying the highest/last ID present in the context store table.
 java.lang.String tableExists()
          Returns the SQL statement for checking whether the context store table already exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sag.osami.contextstore.storage.jdbc.IJDBCDialect
createTable, driver
 

Constructor Detail

GenericJDBCDialect

public GenericJDBCDialect()
Method Detail

tableExists

public java.lang.String tableExists()
Description copied from interface: IJDBCDialect
Returns the SQL statement for checking whether the context store table already exists.

Specified by:
tableExists in interface IJDBCDialect
Returns:
the check SQL statement

createTable

protected java.lang.String createTable(java.lang.String[] colTypes)
Returns a basic CREATE TABLE statement, using the DBConstants.TABLE_AND_COLS list for the table and column names and the colTypes parameter for the column types.

Parameters:
colTypes - the data types of the columns. The order within the array should match the one in DBConstants.COLS
Returns:
the CREATE TABLE SQL statement

dropTable

public java.lang.String dropTable()
Description copied from interface: IJDBCDialect
Returns the SQL statement for dropping the context store table.

Specified by:
dropTable in interface IJDBCDialect
Returns:
the drop table SQL statement

insertContextEvent

public java.lang.String insertContextEvent()
Description copied from interface: IJDBCDialect
Returns the SQL statement for inserting a context event. It contains parameters (?) for each column, ordered as specified in DBConstants.COLS.

Specified by:
insertContextEvent in interface IJDBCDialect
Returns:
the insert SQL statement

loadContextEvent

public java.lang.String loadContextEvent()
Description copied from interface: IJDBCDialect
Returns the SQL statement for loading a context event. It contains one parameter (?) which is bound to the context event ID.

Specified by:
loadContextEvent in interface IJDBCDialect
Returns:
the load SQL statement

deleteContextEvent

public java.lang.String deleteContextEvent()
Description copied from interface: IJDBCDialect
Returns the SQL statement for deleting a context event. It contains one parameter (?) which is bound to the context event ID.

Specified by:
deleteContextEvent in interface IJDBCDialect
Returns:
the delete SQL statement

loadContextEvents

public java.lang.String loadContextEvents(int idsCount)
                                   throws java.lang.UnsupportedOperationException
Description copied from interface: IJDBCDialect
Returns the SQL statement for loading several context events. It contains <idCount> parameters (?) which are bound to the context event IDs.

This operation is optional. If it is not supported, JDBCStorage will load the context events individually, querying one context event at a time.

Specified by:
loadContextEvents in interface IJDBCDialect
Parameters:
idsCount - number of the context event IDs to be loaded
Returns:
the load SQL statement
Throws:
java.lang.UnsupportedOperationException - if the underlying JDBC database does not support loading multiple context events in one query

queryLastID

public java.lang.String queryLastID()
Description copied from interface: IJDBCDialect
Returns the SQL statement for querying the highest/last ID present in the context store table.

Specified by:
queryLastID in interface IJDBCDialect
Returns:
the last ID SQL statement

idParams

protected static java.lang.String idParams(int idsCount)
Convenience method for generating a (?,?,?,...,?) string to be used in an SQL query, especially in loadContextEvents(int)

Parameters:
idsCount - count of the parameters
Returns:
(?,?,?,...,?)