com.is.jrf
Interface DatabasePolicy

All Known Implementing Classes:
HypersonicDatabasePolicy, SQLServerSybaseDatabasePolicy, InstantDBDatabasePolicy, OracleDatabasePolicy, MySQLDatabasePolicy, PostgreSQLDatabasePolicy

public interface DatabasePolicy

This is an interface used to provide database specific behavior. An implementer of this is referenced by the AbstractDomain.

See Also:
OracleDatabasePolicy, SQLServerSybaseDatabasePolicy

Method Summary
 java.lang.String autoIncrementIdentifier()
          auto-increment means that upon insertion, the integer column is automatically given a unique id by the dbms.
 void createSequence(AbstractDomain domain, JDBCHelper aJDBCHelper)
          This method creates a sequence for the domain object.
 java.lang.String currentTimestampSQL()
          This should return the the SQL to use to have the database return the current timestamp.
 java.lang.Long findAutoIncrementId(java.lang.String tableName, java.lang.String columnName, JDBCHelper aJDBCHelper)
           
 java.lang.String formatDate(java.sql.Date sqlDate)
          The result of this is used in SQL.
 java.lang.String formatTimestamp(java.sql.Timestamp ts)
          The return value should be in the string format that the database recognizes as a timestamp.
 java.lang.String outerWhereJoin(java.lang.String mainTableColumn, java.lang.String joinTableColumn)
          Return a string of a name-value pair that represents an SQL outer join that can be used in a WHERE clause.
 java.lang.String sequenceSQL(java.lang.String tableName)
          Return a SQL string to get the next sequence number for a table.
 java.lang.String timestampColumnType()
          This method used when building SQL for creating a table.
 java.lang.String timestampFunction()
          This should return the string value (function name) to put into the SQL to tell the database to insert the current timestamp.
 

Method Detail

sequenceSQL

public java.lang.String sequenceSQL(java.lang.String tableName)
Return a SQL string to get the next sequence number for a table. When executed, this SQL should return a one column, one row result set with an integer.
Parameters:
tableName - a value of type 'String'
Returns:
a value of type 'String'

createSequence

public void createSequence(AbstractDomain domain,
                           JDBCHelper aJDBCHelper)
                    throws java.sql.SQLException
This method creates a sequence for the domain object. If the sequence already exists, it will be reset to the beginning (usually 0).
Parameters:
domain - a value of type 'AbstractDomain'
aJDBCHelper - a value of type 'JDBCHelper'
Throws:
java.sql.SQLException - if an error occurs

timestampFunction

public java.lang.String timestampFunction()
This should return the string value (function name) to put into the SQL to tell the database to insert the current timestamp.
Returns:
a value of type 'String'

formatTimestamp

public java.lang.String formatTimestamp(java.sql.Timestamp ts)
The return value should be in the string format that the database recognizes as a timestamp.
Parameters:
ts - a value of type 'Timestamp'
Returns:
a value of type 'String'

formatDate

public java.lang.String formatDate(java.sql.Date sqlDate)
The result of this is used in SQL. This will format only the date (not the time portion)
Parameters:
sqlDate - a value of type 'java.sql.Date'
Returns:
a value of type 'String'

currentTimestampSQL

public java.lang.String currentTimestampSQL()
This should return the the SQL to use to have the database return the current timestamp.
Returns:
a value of type 'String'

autoIncrementIdentifier

public java.lang.String autoIncrementIdentifier()
auto-increment means that upon insertion, the integer column is automatically given a unique id by the dbms. The auto-increment methods were added for InstantDB, HypsersonicSQL, and any other database that uses this instead of traditional sequencing methods that occur before insertion.

findAutoIncrementId

public java.lang.Long findAutoIncrementId(java.lang.String tableName,
                                          java.lang.String columnName,
                                          JDBCHelper aJDBCHelper)

outerWhereJoin

public java.lang.String outerWhereJoin(java.lang.String mainTableColumn,
                                       java.lang.String joinTableColumn)
Return a string of a name-value pair that represents an SQL outer join that can be used in a WHERE clause. i.e. The result would look like this for Oracle: 'Tbl1.Id=Tbl2.Id(+)'
Parameters:
mainTableColumn - a value of type 'String'
joinTableColumn - a value of type 'String'
Returns:
a value of type 'String'

timestampColumnType

public java.lang.String timestampColumnType()
This method used when building SQL for creating a table.
Returns:
a value of type 'String'