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
SQLException
protected String executeFunctionFormat()
protected String executeFunctionSQL(String function)
protected String dummyTable()
public String getTruncateTableSQL(TableProperties properties)
Dialect
getTruncateTableSQL
in interface Dialect
properties
- table meta dataDialect.getTruncateTableSQL(net.sf.hajdbc.TableProperties)
protected String truncateTableFormat()
public String getCreateForeignKeyConstraintSQL(ForeignKeyConstraint key)
Dialect
getCreateForeignKeyConstraintSQL
in interface Dialect
key
- foreign key constraint meta dataDialect.getCreateForeignKeyConstraintSQL(net.sf.hajdbc.ForeignKeyConstraint)
protected String createForeignKeyConstraintFormat()
public String getDropForeignKeyConstraintSQL(ForeignKeyConstraint key)
Dialect
getDropForeignKeyConstraintSQL
in interface Dialect
key
- foreign key constraint meta dataDialect.getDropForeignKeyConstraintSQL(net.sf.hajdbc.ForeignKeyConstraint)
protected String dropForeignKeyConstraintFormat()
protected String dropConstraintFormat()
public String getCreateUniqueConstraintSQL(UniqueConstraint constraint)
Dialect
getCreateUniqueConstraintSQL
in interface Dialect
constraint
- unique constraint meta dataDialect.getCreateUniqueConstraintSQL(net.sf.hajdbc.UniqueConstraint)
protected String createUniqueConstraintFormat()
public String getDropUniqueConstraintSQL(UniqueConstraint constraint)
Dialect
getDropUniqueConstraintSQL
in interface Dialect
constraint
- unique constraint meta dataDialect.getDropUniqueConstraintSQL(net.sf.hajdbc.UniqueConstraint)
protected String dropUniqueConstraintFormat()
public boolean isSelectForUpdate(String sql)
Dialect
isSelectForUpdate
in interface Dialect
sql
- a SQL statementDialect.isSelectForUpdate(java.lang.String)
public List<String> getDefaultSchemas(DatabaseMetaData metaData) throws SQLException
Dialect
getDefaultSchemas
in interface Dialect
SQLException
Dialect.getDefaultSchemas(java.sql.DatabaseMetaData)
protected String executeFunction(Connection connection, String function) throws SQLException
SQLException
protected List<String> executeQuery(Connection connection, String sql) throws SQLException
SQLException
public SequenceSupport getSequenceSupport()
getSequenceSupport
in interface Dialect
Dialect.getSequenceSupport()
public String parseSequence(String sql)
SequenceSupport
parseSequence
in interface SequenceSupport
sql
- a SQL statementSequenceSupport.parseSequence(java.lang.String)
public int getColumnType(ColumnProperties properties)
Dialect
getColumnType
in interface Dialect
properties
- table column meta dataDialect.getColumnType(net.sf.hajdbc.ColumnProperties)
public Collection<SequenceProperties> getSequences(DatabaseMetaData metaData, SequencePropertiesFactory factory) throws SQLException
getSequences
in interface SequenceSupport
metaData
- database meta dataSQLException
SequenceSupport.getSequences(java.sql.DatabaseMetaData, net.sf.hajdbc.SequencePropertiesFactory)
protected String sequenceTableType()
public String getNextSequenceValueSQL(SequenceProperties sequence)
SequenceSupport
getNextSequenceValueSQL
in interface SequenceSupport
sequence
- a sequence nameSequenceSupport.getNextSequenceValueSQL(net.sf.hajdbc.SequenceProperties)
protected String nextSequenceValueFormat()
public String getAlterSequenceSQL(SequenceProperties sequence, long value)
SequenceSupport
getAlterSequenceSQL
in interface SequenceSupport
sequence
- a sequence namevalue
- a sequence valueSequenceSupport.getAlterSequenceSQL(net.sf.hajdbc.SequenceProperties, long)
protected String alterSequenceFormat()
public IdentityColumnSupport getIdentityColumnSupport()
getIdentityColumnSupport
in interface Dialect
Dialect.getIdentityColumnSupport()
public String parseInsertTable(String sql)
IdentityColumnSupport
parseInsertTable
in interface IdentityColumnSupport
sql
- a SQL statementpublic String getAlterIdentityColumnSQL(TableProperties table, ColumnProperties column, long value)
IdentityColumnSupport
getAlterIdentityColumnSQL
in interface IdentityColumnSupport
table
- a sequence namecolumn
- a sequence namevalue
- a sequence valueprotected String alterIdentityColumnFormat()
public String evaluateCurrentDate(String sql, Date date)
evaluateCurrentDate
in interface Dialect
sql
- 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 Dialect
sql
- 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 Dialect
sql
- an SQL statementtimestamp
- the replacement timestampDialect.evaluateCurrentTimestamp(java.lang.String, java.sql.Timestamp)
protected String timestampLiteralFormat()
public String evaluateRand(String sql)
evaluateRand
in interface Dialect
sql
- an SQL statementDialect.evaluateRand(java.lang.String)
public boolean indicatesFailure(SQLException e)
indicatesFailure
in interface Dialect
e
- 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 Dialect
e
- an exceptionDialect.indicatesFailure(javax.transaction.xa.XAException)
protected Set<Integer> failureXAErrorCodes()
public DumpRestoreSupport getDumpRestoreSupport()
getDumpRestoreSupport
in interface Dialect
Dialect.getDumpRestoreSupport()
public TriggerSupport getTriggerSupport()
getTriggerSupport
in interface Dialect
Dialect.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 TriggerSupport
TriggerSupport.getDropTriggerSQL(String, net.sf.hajdbc.TableProperties)
protected String dropTriggerFormat()
public String getTriggerRowAlias(TriggerTime time)
getTriggerRowAlias
in interface TriggerSupport
TriggerSupport.getTriggerRowAlias(net.sf.hajdbc.TriggerTime)
public String getCreateSchemaSQL(String schema)
getCreateSchemaSQL
in interface Dialect
Dialect.getCreateSchemaSQL(java.lang.String)
protected String createSchemaFormat()
public String getDropSchemaSQL(String schema)
getDropSchemaSQL
in interface Dialect
Dialect.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 Dialect
metaData
- a DatabaseMetaData implementationSQLException
- if an error occurs access DatabaseMetaDatapublic Map<String,ColumnProperties> getColumns(DatabaseMetaData metaData, QualifiedName table, ColumnPropertiesFactory factory) throws SQLException
getColumns
in interface Dialect
metaData
- 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 Dialect
metaData
- 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 Dialect
metaData
- 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 Dialect
metaData
- 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 Dialect
columns
- the columns of a tableSQLException
public Map<Integer,Map.Entry<String,Integer>> getTypes(DatabaseMetaData metaData) throws SQLException
getTypes
in interface Dialect
metaData
- database meta dataSQLException
Dialect.getTypes(java.sql.DatabaseMetaData)
public IdentifierNormalizer createIdentifierNormalizer(DatabaseMetaData metaData) throws SQLException
createIdentifierNormalizer
in interface Dialect
SQLException
protected Pattern identifierPattern(DatabaseMetaData metaData) throws SQLException
SQLException
protected Set<String> reservedIdentifiers(DatabaseMetaData metaData) throws SQLException
SQLException
public QualifiedNameFactory createQualifiedNameFactory(DatabaseMetaData metaData, IdentifierNormalizer normalizer) throws SQLException
createQualifiedNameFactory
in interface Dialect
SQLException
public ColumnPropertiesFactory createColumnPropertiesFactory(IdentifierNormalizer normalizer)
createColumnPropertiesFactory
in interface Dialect
public SequencePropertiesFactory createSequencePropertiesFactory(QualifiedNameFactory factory)
createSequencePropertiesFactory
in interface SequenceSupport
public ForeignKeyConstraintFactory createForeignKeyConstraintFactory(QualifiedNameFactory factory)
createForeignKeyConstraintFactory
in interface Dialect
public UniqueConstraintFactory createUniqueConstraintFactory(IdentifierNormalizer normalizer)
createUniqueConstraintFactory
in interface Dialect
public boolean isValid(Connection connection) throws SQLException
isValid
in interface Dialect
SQLException
public <Z,D extends Database<Z>> ConnectionProperties getConnectionProperties(D database, Decoder decoder) throws SQLException
getConnectionProperties
in interface Dialect
SQLException
Copyright © 2004–2014 Paul Ferraro. All rights reserved.