net.sf.hajdbc
Interface Dialect

All Known Implementing Classes:
DB2Dialect, DerbyDialect, FirebirdDialect, H2Dialect, HSQLDBDialect, IngresDialect, MaxDBDialect, MckoiDialect, MySQLDialect, OracleDialect, PostgreSQLDialect, StandardDialect, SybaseDialect

public interface Dialect

Encapsulates database vendor specific SQL syntax.

Since:
1.1
Author:
Paul Ferraro

Method Summary
 String evaluateCurrentDate(String sql, Date date)
          Replaces non-deterministic CURRENT_DATE functions with deterministic static values.
 String evaluateCurrentTime(String sql, Time time)
          Replaces non-deterministic CURRENT_TIME functions with deterministic static values.
 String evaluateCurrentTimestamp(String sql, Timestamp timestamp)
          Replaces non-deterministic CURRENT_TIMESTAMP functions with deterministic static values.
 String evaluateRand(String sql)
          Replaces non-deterministic RAND() functions with deterministic static values.
 String getAlterIdentityColumnSQL(TableProperties table, ColumnProperties column, long value)
          Returns a SQL statement used reset the current value of an identity column.
 String getAlterSequenceSQL(SequenceProperties sequence, long value)
          Returns a SQL statement used reset the current value of a sequence.
 int getColumnType(ColumnProperties properties)
          Returns the data type of the specified column of the specified schema and table.
 String getCreateForeignKeyConstraintSQL(ForeignKeyConstraint constraint)
          Returns a SQL statement used to create a foreign key constraint.
 String getCreateUniqueConstraintSQL(UniqueConstraint constraint)
          Returns a SQL statement used to create a unique constraint.
 List<String> getDefaultSchemas(DatabaseMetaData metaData)
          Returns a search path of schemas
 String getDropForeignKeyConstraintSQL(ForeignKeyConstraint constraint)
          Returns a SQL statement used to drop a foreign key constraint.
 String getDropUniqueConstraintSQL(UniqueConstraint constraint)
          Returns a SQL statement used to drop a unique constraint.
 Pattern getIdentifierPattern(DatabaseMetaData metaData)
          Returns a pattern for identifiers that do not require quoting
 String getNextSequenceValueSQL(SequenceProperties sequence)
          Returns a SQL statement for obtaining the next value the specified sequence
 Collection<QualifiedName> getSequences(DatabaseMetaData metaData)
          Returns a collection of all sequences in this database.
 String getSimpleSQL()
          Returns a simple SQL statement used to validate whether a database is alive or not.
 String getTruncateTableSQL(TableProperties properties)
          Returns a SQL statement used to truncate a table.
 boolean isIdentity(ColumnProperties properties)
          Indicates whether or not the specified column is an identity column.
 boolean isSelectForUpdate(String sql)
          Determines whether the specified SQL is a SELECT ...
 String parseInsertTable(String sql)
          Parses a table name from the specified INSERT SQL statement that may contain identity columns.
 String parseSequence(String sql)
          Parses a sequence name from the specified SQL statement.
 

Method Detail

getSimpleSQL

String getSimpleSQL()
                    throws SQLException
Returns a simple SQL statement used to validate whether a database is alive or not.

Returns:
a SQL statement
Throws:
SQLException

getTruncateTableSQL

String getTruncateTableSQL(TableProperties properties)
                           throws SQLException
Returns a SQL statement used to truncate a table.

Parameters:
properties - table meta data
Returns:
a SQL statement
Throws:
SQLException - if there was an error fetching meta data.

getCreateForeignKeyConstraintSQL

String getCreateForeignKeyConstraintSQL(ForeignKeyConstraint constraint)
                                        throws SQLException
Returns a SQL statement used to create a foreign key constraint.

Parameters:
constraint - foreign key constraint meta data
Returns:
a SQL statement
Throws:
SQLException - if there was an error fetching meta data.

getDropForeignKeyConstraintSQL

String getDropForeignKeyConstraintSQL(ForeignKeyConstraint constraint)
                                      throws SQLException
Returns a SQL statement used to drop a foreign key constraint.

Parameters:
constraint - foreign key constraint meta data
Returns:
a SQL statement
Throws:
SQLException - if there was an error fetching meta data.

getCreateUniqueConstraintSQL

String getCreateUniqueConstraintSQL(UniqueConstraint constraint)
                                    throws SQLException
Returns a SQL statement used to create a unique constraint.

Parameters:
constraint - unique constraint meta data
Returns:
a SQL statement
Throws:
SQLException - if there was an error fetching meta data.

getDropUniqueConstraintSQL

String getDropUniqueConstraintSQL(UniqueConstraint constraint)
                                  throws SQLException
Returns a SQL statement used to drop a unique constraint.

Parameters:
constraint - unique constraint meta data
Returns:
a SQL statement
Throws:
SQLException - if there was an error fetching meta data.

isSelectForUpdate

boolean isSelectForUpdate(String sql)
                          throws SQLException
Determines whether the specified SQL is a SELECT ... FOR UPDATE statement

Parameters:
sql - a SQL statement
Returns:
true if this is a SELECT ... FOR UPDATE statement, false if it is not
Throws:
SQLException - if there was an error fetching meta data.

getColumnType

int getColumnType(ColumnProperties properties)
                  throws SQLException
Returns the data type of the specified column of the specified schema and table. This method is intended to correct JDBC driver type mapping quirks.

Parameters:
properties - table column meta data
Returns:
the JDBC data type of this column
Throws:
SQLException

parseInsertTable

String parseInsertTable(String sql)
                        throws SQLException
Parses a table name from the specified INSERT SQL statement that may contain identity columns.

Parameters:
sql - a SQL statement
Returns:
the name of a table, or null if this SQL statement is not an INSERT statement or this dialect does not support identity columns
Throws:
SQLException
Since:
2.0

isIdentity

boolean isIdentity(ColumnProperties properties)
                   throws SQLException
Indicates whether or not the specified column is an identity column.

Parameters:
properties - a table column
Returns:
true, if this column is an identity column, false otherwise
Throws:
SQLException
Since:
2.0

parseSequence

String parseSequence(String sql)
                     throws SQLException
Parses a sequence name from the specified SQL statement.

Parameters:
sql - a SQL statement
Returns:
the name of a sequence, or null if this SQL statement does not reference a sequence or this dialect does not support sequences
Throws:
SQLException
Since:
2.0

getSequences

Collection<QualifiedName> getSequences(DatabaseMetaData metaData)
                                       throws SQLException
Returns a collection of all sequences in this database.

Parameters:
metaData - database meta data
Returns:
a collection of sequence names
Throws:
SQLException
Since:
2.0

getNextSequenceValueSQL

String getNextSequenceValueSQL(SequenceProperties sequence)
                               throws SQLException
Returns a SQL statement for obtaining the next value the specified sequence

Parameters:
sequence - a sequence name
Returns:
a SQL statement
Throws:
SQLException
Since:
2.0

getAlterSequenceSQL

String getAlterSequenceSQL(SequenceProperties sequence,
                           long value)
                           throws SQLException
Returns a SQL statement used reset the current value of a sequence.

Parameters:
sequence - a sequence name
value - a sequence value
Returns:
a SQL statement
Throws:
SQLException
Since:
2.0

getAlterIdentityColumnSQL

String getAlterIdentityColumnSQL(TableProperties table,
                                 ColumnProperties column,
                                 long value)
                                 throws SQLException
Returns a SQL statement used reset the current value of an identity column.

Parameters:
table - a sequence name
column - a sequence name
value - a sequence value
Returns:
a SQL statement
Throws:
SQLException
Since:
2.0.2

getDefaultSchemas

List<String> getDefaultSchemas(DatabaseMetaData metaData)
                               throws SQLException
Returns a search path of schemas

Parameters:
metaData -
Returns:
a list of schema names
Throws:
SQLException
Since:
2.0

getIdentifierPattern

Pattern getIdentifierPattern(DatabaseMetaData metaData)
                             throws SQLException
Returns a pattern for identifiers that do not require quoting

Parameters:
metaData -
Returns:
a regular expression pattern
Throws:
SQLException
Since:
2.0.2

evaluateCurrentDate

String evaluateCurrentDate(String sql,
                           Date date)
                           throws SQLException
Replaces non-deterministic CURRENT_DATE functions with deterministic static values.

Parameters:
sql - an SQL statement
date - the replacement date
Returns:
an equivalent deterministic SQL statement
Throws:
SQLException
Since:
2.0.2

evaluateCurrentTime

String evaluateCurrentTime(String sql,
                           Time time)
                           throws SQLException
Replaces non-deterministic CURRENT_TIME functions with deterministic static values.

Parameters:
sql - an SQL statement
time - the replacement time
Returns:
an equivalent deterministic SQL statement
Throws:
SQLException
Since:
2.0.2

evaluateCurrentTimestamp

String evaluateCurrentTimestamp(String sql,
                                Timestamp timestamp)
                                throws SQLException
Replaces non-deterministic CURRENT_TIMESTAMP functions with deterministic static values.

Parameters:
sql - an SQL statement
timestamp - the replacement timestamp
Returns:
an equivalent deterministic SQL statement
Throws:
SQLException
Since:
2.0.2

evaluateRand

String evaluateRand(String sql)
                    throws SQLException
Replaces non-deterministic RAND() functions with deterministic static values.

Parameters:
sql - an SQL statement
Returns:
an equivalent deterministic SQL statement
Throws:
SQLException
Since:
2.0.2