public class StandardDialect extends Object implements Dialect, SequenceSupport, IdentityColumnSupport, TriggerSupport
TriggerSupport.TriggerEventEnum, TriggerSupport.TriggerTimeEnum| Modifier and Type | Field and Description |
|---|---|
protected static String[] |
SQL_2003_RESERVED_KEY_WORDS |
| Constructor and Description |
|---|
StandardDialect() |
| Modifier and Type | Method and Description |
|---|---|
protected String |
alterIdentityColumnFormat() |
protected String |
alterSequenceFormat() |
ColumnPropertiesFactory |
createColumnPropertiesFactory(IdentifierNormalizer normalizer) |
ForeignKeyConstraintFactory |
createForeignKeyConstraintFactory(QualifiedNameFactory factory) |
protected String |
createForeignKeyConstraintFormat() |
IdentifierNormalizer |
createIdentifierNormalizer(DatabaseMetaData metaData) |
QualifiedNameFactory |
createQualifiedNameFactory(DatabaseMetaData metaData,
IdentifierNormalizer normalizer) |
protected String |
createSchemaFormat() |
SequencePropertiesFactory |
createSequencePropertiesFactory(QualifiedNameFactory factory) |
protected String |
createTriggerFormat() |
UniqueConstraintFactory |
createUniqueConstraintFactory(IdentifierNormalizer normalizer) |
protected String |
createUniqueConstraintFormat() |
protected String |
currentDatePattern() |
protected String |
currentTimePattern() |
protected String |
currentTimestampPattern() |
protected String |
dateLiteralFormat() |
protected String |
dropConstraintFormat() |
protected String |
dropForeignKeyConstraintFormat() |
protected String |
dropSchemaFormat() |
protected String |
dropTriggerFormat() |
protected String |
dropUniqueConstraintFormat() |
protected String |
dummyTable() |
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.
|
protected String |
executeFunction(Connection connection,
String function) |
protected String |
executeFunctionFormat() |
protected String |
executeFunctionSQL(String function) |
protected List<String> |
executeQuery(Connection connection,
String sql) |
protected Set<Integer> |
failureXAErrorCodes() |
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.
|
Map<String,ColumnProperties> |
getColumns(DatabaseMetaData metaData,
QualifiedName table,
ColumnPropertiesFactory factory)
Returns the columns of the specified table.
|
int |
getColumnType(ColumnProperties properties)
Returns the data type of the specified column of the specified schema and table.
|
<Z,D extends Database<Z>> |
getConnectionProperties(D database,
Decoder decoder) |
String |
getCreateForeignKeyConstraintSQL(ForeignKeyConstraint key)
Returns a SQL statement used to create a foreign key constraint.
|
String |
getCreateSchemaSQL(String schema) |
String |
getCreateTriggerSQL(String name,
TableProperties table,
TriggerEvent event,
String action) |
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 key)
Returns a SQL statement used to drop a foreign key constraint.
|
String |
getDropSchemaSQL(String schema) |
String |
getDropTriggerSQL(String name,
TableProperties table) |
String |
getDropUniqueConstraintSQL(UniqueConstraint constraint)
Returns a SQL statement used to drop a unique constraint.
|
DumpRestoreSupport |
getDumpRestoreSupport() |
Collection<ForeignKeyConstraint> |
getForeignKeyConstraints(DatabaseMetaData metaData,
QualifiedName table,
ForeignKeyConstraintFactory factory)
Returns the foreign key constraints on the specified table.
|
Collection<String> |
getIdentityColumns(Collection<ColumnProperties> columns)
Identifies any identity columns from the from the specified collection of columns
|
IdentityColumnSupport |
getIdentityColumnSupport() |
String |
getNextSequenceValueSQL(SequenceProperties sequence)
Returns a SQL statement for obtaining the next value the specified sequence
|
UniqueConstraint |
getPrimaryKey(DatabaseMetaData metaData,
QualifiedName table,
UniqueConstraintFactory factory)
Returns the primary key of the specified table.
|
Collection<SequenceProperties> |
getSequences(DatabaseMetaData metaData,
SequencePropertiesFactory factory)
Returns a collection of sequences using dialect specific logic.
|
SequenceSupport |
getSequenceSupport() |
Collection<QualifiedName> |
getTables(DatabaseMetaData metaData,
QualifiedNameFactory factory)
Returns all tables in this database mapped by schema.
|
String |
getTriggerRowAlias(TriggerTime time) |
TriggerSupport |
getTriggerSupport() |
String |
getTruncateTableSQL(TableProperties properties)
Returns a SQL statement used to truncate a table.
|
Map<Integer,Map.Entry<String,Integer>> |
getTypes(DatabaseMetaData metaData)
Returns a mapping of standard JDBC types to native types
|
Collection<UniqueConstraint> |
getUniqueConstraints(DatabaseMetaData metaData,
QualifiedName table,
UniqueConstraint primaryKey,
UniqueConstraintFactory factory)
Returns the unique constraints on the specified table - excluding the primary key of the table.
|
protected Pattern |
identifierPattern(DatabaseMetaData metaData) |
protected boolean |
indicatesFailure(int code)
Indicates whether the specified vendor-specific error code indicates a database failure that should result in a database deactivation.
|
boolean |
indicatesFailure(SQLException e)
Determines whether the specified exception indicates a catastrophic error.
|
protected boolean |
indicatesFailure(String sqlState)
Indicates whether the specified SQLState indicates a database failure that should result in a database deactivation.
|
boolean |
indicatesFailure(XAException e)
Determines whether the specified exception indicates a catastrophic error.
|
protected String |
insertIntoTablePattern() |
boolean |
isSelectForUpdate(String sql)
Determines whether the specified SQL is a SELECT ...
|
boolean |
isValid(Connection connection) |
protected String |
locatorPattern() |
protected boolean |
meetsRequirement(int minMajor,
int minMinor) |
protected String |
nextSequenceValueFormat() |
protected String |
parse(Pattern pattern,
String string) |
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.
|
protected String |
randomPattern() |
protected Set<String> |
reservedIdentifiers(DatabaseMetaData metaData) |
protected String |
schemaPattern(DatabaseMetaData metaData) |
protected String |
selectForUpdatePattern() |
protected String |
sequencePattern() |
protected String |
sequenceTableType() |
protected String |
timeLiteralFormat() |
protected String |
timestampLiteralFormat() |
protected String |
truncateTableFormat() |
protected String |
vendorPattern() |
protected static final String[] SQL_2003_RESERVED_KEY_WORDS
public StandardDialect()
protected String vendorPattern()
protected String locatorPattern()
protected String selectForUpdatePattern()
protected String insertIntoTablePattern()
protected String sequencePattern()
protected String currentDatePattern()
protected String currentTimePattern()
protected String currentTimestampPattern()
protected String randomPattern()
protected String schemaPattern(DatabaseMetaData metaData) throws SQLException
SQLExceptionprotected String executeFunctionFormat()
protected String executeFunctionSQL(String function)
protected String dummyTable()
public String getTruncateTableSQL(TableProperties properties)
DialectgetTruncateTableSQL in interface Dialectproperties - table meta dataDialect.getTruncateTableSQL(net.sf.hajdbc.TableProperties)protected String truncateTableFormat()
public String getCreateForeignKeyConstraintSQL(ForeignKeyConstraint key)
DialectgetCreateForeignKeyConstraintSQL in interface Dialectkey - foreign key constraint meta dataDialect.getCreateForeignKeyConstraintSQL(net.sf.hajdbc.ForeignKeyConstraint)protected String createForeignKeyConstraintFormat()
public String getDropForeignKeyConstraintSQL(ForeignKeyConstraint key)
DialectgetDropForeignKeyConstraintSQL in interface Dialectkey - foreign key constraint meta dataDialect.getDropForeignKeyConstraintSQL(net.sf.hajdbc.ForeignKeyConstraint)protected String dropForeignKeyConstraintFormat()
protected String dropConstraintFormat()
public String getCreateUniqueConstraintSQL(UniqueConstraint constraint)
DialectgetCreateUniqueConstraintSQL in interface Dialectconstraint - unique constraint meta dataDialect.getCreateUniqueConstraintSQL(net.sf.hajdbc.UniqueConstraint)protected String createUniqueConstraintFormat()
public String getDropUniqueConstraintSQL(UniqueConstraint constraint)
DialectgetDropUniqueConstraintSQL in interface Dialectconstraint - unique constraint meta dataDialect.getDropUniqueConstraintSQL(net.sf.hajdbc.UniqueConstraint)protected String dropUniqueConstraintFormat()
public boolean isSelectForUpdate(String sql)
DialectisSelectForUpdate in interface Dialectsql - a SQL statementDialect.isSelectForUpdate(java.lang.String)public List<String> getDefaultSchemas(DatabaseMetaData metaData) throws SQLException
DialectgetDefaultSchemas in interface DialectSQLExceptionDialect.getDefaultSchemas(java.sql.DatabaseMetaData)protected String executeFunction(Connection connection, String function) throws SQLException
SQLExceptionprotected List<String> executeQuery(Connection connection, String sql) throws SQLException
SQLExceptionpublic SequenceSupport getSequenceSupport()
getSequenceSupport in interface DialectDialect.getSequenceSupport()public String parseSequence(String sql)
SequenceSupportparseSequence in interface SequenceSupportsql - a SQL statementSequenceSupport.parseSequence(java.lang.String)public int getColumnType(ColumnProperties properties)
DialectgetColumnType in interface Dialectproperties - table column meta dataDialect.getColumnType(net.sf.hajdbc.ColumnProperties)public Collection<SequenceProperties> getSequences(DatabaseMetaData metaData, SequencePropertiesFactory factory) throws SQLException
getSequences in interface SequenceSupportmetaData - database meta dataSQLExceptionSequenceSupport.getSequences(java.sql.DatabaseMetaData, net.sf.hajdbc.SequencePropertiesFactory)protected String sequenceTableType()
public String getNextSequenceValueSQL(SequenceProperties sequence)
SequenceSupportgetNextSequenceValueSQL in interface SequenceSupportsequence - a sequence nameSequenceSupport.getNextSequenceValueSQL(net.sf.hajdbc.SequenceProperties)protected String nextSequenceValueFormat()
public String getAlterSequenceSQL(SequenceProperties sequence, long value)
SequenceSupportgetAlterSequenceSQL in interface SequenceSupportsequence - a sequence namevalue - a sequence valueSequenceSupport.getAlterSequenceSQL(net.sf.hajdbc.SequenceProperties, long)protected String alterSequenceFormat()
public IdentityColumnSupport getIdentityColumnSupport()
getIdentityColumnSupport in interface DialectDialect.getIdentityColumnSupport()public String parseInsertTable(String sql)
IdentityColumnSupportparseInsertTable in interface IdentityColumnSupportsql - a SQL statementpublic String getAlterIdentityColumnSQL(TableProperties table, ColumnProperties column, long value)
IdentityColumnSupportgetAlterIdentityColumnSQL in interface IdentityColumnSupporttable - a sequence namecolumn - a sequence namevalue - a sequence valueprotected String alterIdentityColumnFormat()
public String evaluateCurrentDate(String sql, Date date)
evaluateCurrentDate in interface Dialectsql - an SQL statementdate - the replacement dateDialect.evaluateCurrentDate(java.lang.String, java.sql.Date)protected String dateLiteralFormat()
public String evaluateCurrentTime(String sql, Time time)
evaluateCurrentTime in interface Dialectsql - an SQL statementtime - the replacement timeDialect.evaluateCurrentTime(java.lang.String, java.sql.Time)protected String timeLiteralFormat()
public String evaluateCurrentTimestamp(String sql, Timestamp timestamp)
evaluateCurrentTimestamp in interface Dialectsql - an SQL statementtimestamp - the replacement timestampDialect.evaluateCurrentTimestamp(java.lang.String, java.sql.Timestamp)protected String timestampLiteralFormat()
public String evaluateRand(String sql)
evaluateRand in interface Dialectsql - an SQL statementDialect.evaluateRand(java.lang.String)public boolean indicatesFailure(SQLException e)
indicatesFailure in interface Dialecte - an exceptionDialect.indicatesFailure(java.sql.SQLException)protected boolean indicatesFailure(String sqlState)
sqlState - a SQL:2003 or X/Open SQLStateprotected boolean indicatesFailure(int code)
code - a vendor-specific error codepublic boolean indicatesFailure(XAException e)
indicatesFailure in interface Dialecte - an exceptionDialect.indicatesFailure(javax.transaction.xa.XAException)protected Set<Integer> failureXAErrorCodes()
public DumpRestoreSupport getDumpRestoreSupport()
getDumpRestoreSupport in interface DialectDialect.getDumpRestoreSupport()public TriggerSupport getTriggerSupport()
getTriggerSupport in interface DialectDialect.getTriggerSupport()public String getCreateTriggerSQL(String name, TableProperties table, TriggerEvent event, String action)
protected String createTriggerFormat()
public String getDropTriggerSQL(String name, TableProperties table)
getDropTriggerSQL in interface TriggerSupportTriggerSupport.getDropTriggerSQL(String, net.sf.hajdbc.TableProperties)protected String dropTriggerFormat()
public String getTriggerRowAlias(TriggerTime time)
getTriggerRowAlias in interface TriggerSupportTriggerSupport.getTriggerRowAlias(net.sf.hajdbc.TriggerTime)public String getCreateSchemaSQL(String schema)
getCreateSchemaSQL in interface DialectDialect.getCreateSchemaSQL(java.lang.String)protected String createSchemaFormat()
public String getDropSchemaSQL(String schema)
getDropSchemaSQL in interface DialectDialect.getDropSchemaSQL(java.lang.String)protected String dropSchemaFormat()
protected boolean meetsRequirement(int minMajor, int minMinor)
public Collection<QualifiedName> getTables(DatabaseMetaData metaData, QualifiedNameFactory factory) throws SQLException
getTables in interface DialectmetaData - a DatabaseMetaData implementationSQLException - if an error occurs access DatabaseMetaDatapublic Map<String,ColumnProperties> getColumns(DatabaseMetaData metaData, QualifiedName table, ColumnPropertiesFactory factory) throws SQLException
getColumns in interface DialectmetaData - a DatabaseMetaData implementationtable - a schema qualified table nameSQLException - if an error occurs access DatabaseMetaDatapublic UniqueConstraint getPrimaryKey(DatabaseMetaData metaData, QualifiedName table, UniqueConstraintFactory factory) throws SQLException
getPrimaryKey in interface DialectmetaData - a DatabaseMetaData implementationtable - a schema qualified table nameSQLException - if an error occurs access DatabaseMetaDatapublic Collection<ForeignKeyConstraint> getForeignKeyConstraints(DatabaseMetaData metaData, QualifiedName table, ForeignKeyConstraintFactory factory) throws SQLException
getForeignKeyConstraints in interface DialectmetaData - a DatabaseMetaData implementationtable - a schema qualified table nameSQLException - if an error occurs access DatabaseMetaDatapublic Collection<UniqueConstraint> getUniqueConstraints(DatabaseMetaData metaData, QualifiedName table, UniqueConstraint primaryKey, UniqueConstraintFactory factory) throws SQLException
getUniqueConstraints in interface DialectmetaData - a schema qualified table nametable - a qualified table nameprimaryKey - the primary key of this tableSQLException - if an error occurs access DatabaseMetaDatapublic Collection<String> getIdentityColumns(Collection<ColumnProperties> columns) throws SQLException
getIdentityColumns in interface Dialectcolumns - the columns of a tableSQLExceptionpublic Map<Integer,Map.Entry<String,Integer>> getTypes(DatabaseMetaData metaData) throws SQLException
getTypes in interface DialectmetaData - database meta dataSQLExceptionDialect.getTypes(java.sql.DatabaseMetaData)public IdentifierNormalizer createIdentifierNormalizer(DatabaseMetaData metaData) throws SQLException
createIdentifierNormalizer in interface DialectSQLExceptionprotected Pattern identifierPattern(DatabaseMetaData metaData) throws SQLException
SQLExceptionprotected Set<String> reservedIdentifiers(DatabaseMetaData metaData) throws SQLException
SQLExceptionpublic QualifiedNameFactory createQualifiedNameFactory(DatabaseMetaData metaData, IdentifierNormalizer normalizer) throws SQLException
createQualifiedNameFactory in interface DialectSQLExceptionpublic ColumnPropertiesFactory createColumnPropertiesFactory(IdentifierNormalizer normalizer)
createColumnPropertiesFactory in interface Dialectpublic SequencePropertiesFactory createSequencePropertiesFactory(QualifiedNameFactory factory)
createSequencePropertiesFactory in interface SequenceSupportpublic ForeignKeyConstraintFactory createForeignKeyConstraintFactory(QualifiedNameFactory factory)
createForeignKeyConstraintFactory in interface Dialectpublic UniqueConstraintFactory createUniqueConstraintFactory(IdentifierNormalizer normalizer)
createUniqueConstraintFactory in interface Dialectpublic boolean isValid(Connection connection) throws SQLException
isValid in interface DialectSQLExceptionpublic <Z,D extends Database<Z>> ConnectionProperties getConnectionProperties(D database, Decoder decoder) throws SQLException
getConnectionProperties in interface DialectSQLExceptionCopyright © 2004–2014 Paul Ferraro. All rights reserved.