com.sag.osami.contextstore.storage.jdbc
Interface IJDBCDialect

All Superinterfaces:
DBConstants
All Known Implementing Classes:
DerbyDialect, GenericJDBCDialect, MysqlDialect, PostgresqlDialect, SqliteDialect

public interface IJDBCDialect
extends DBConstants

This interface provides methods for getting SQL statements for the various tasks a storage implementation must handle, i.e.:

of ContextEvents (by ID(s)) as well as statements for creating and dropping the ContextStore table and also for querying the last given ContextEvent ID [before the ContextStore was shutdown].

This interface abstracts away the various small SQL syntax differences between database server implementations and enables to re-use the same JDBC-based storage implementation for all JDBC-compatible DBs.

An implementation of a JDBC dialect is typically extremely lightweight as it simply must return a bunch of (usually) static SQL strings.

Important note: Most of the query strings are used in a context where parameter binding is performed; those parameters are in a well-defined order and the query strings should contain the according "?" placeholders. See the query methods documentation for details.

See Also:
JDBCStorage, GenericJDBCDialect

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
 
Method Summary
 java.lang.String createTable()
          Returns the SQL statement for creating the context store table.
 java.lang.String deleteContextEvent()
          Returns the SQL statement for deleting a context event.
 java.lang.String driver()
          Returns the fully qualified class name of the JDBC driver to be used.
 java.lang.String dropTable()
          Returns the SQL statement for dropping the context store table.
 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.
 

Method Detail

driver

java.lang.String driver()
Returns the fully qualified class name of the JDBC driver to be used.

Returns:
the JDBC driver class name

queryLastID

java.lang.String queryLastID()
Returns the SQL statement for querying the highest/last ID present in the context store table.

Returns:
the last ID SQL statement

tableExists

java.lang.String tableExists()
Returns the SQL statement for checking whether the context store table already exists.

Returns:
the check SQL statement

createTable

java.lang.String createTable()
Returns the SQL statement for creating the context store table.

Be aware that the ID column should not be auto incremented by the database. ID generation is handled by the ContextStore.

Returns:
the create table SQL statement

dropTable

java.lang.String dropTable()
Returns the SQL statement for dropping the context store table.

Returns:
the drop table SQL statement

insertContextEvent

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

Returns:
the insert SQL statement

loadContextEvents

java.lang.String loadContextEvents(int idsCount)
                                   throws java.lang.UnsupportedOperationException
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.

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

loadContextEvent

java.lang.String loadContextEvent()
Returns the SQL statement for loading a context event. It contains one parameter (?) which is bound to the context event ID.

Returns:
the load SQL statement

deleteContextEvent

java.lang.String deleteContextEvent()
Returns the SQL statement for deleting a context event. It contains one parameter (?) which is bound to the context event ID.

Returns:
the delete SQL statement