public abstract class Dialect
extends java.lang.Object
Dialect class
to add methods required by the P2J persistence framework. The
implementations of these methods are necessarily specific to the backing
database and may be different for different database vendors.
NOTE: a longer term goal is to eliminate this interface by merging these
methods back into the mainstream Hibernate Dialect class.
| Modifier and Type | Class and Description |
|---|---|
static interface |
Dialect.WeightAggregator
Helper interface for weights' aggregation
|
| Modifier and Type | Field and Description |
|---|---|
(package private) static java.lang.String |
CASE_TYPE_TOK
Token used to mark placeholder for varchar type when generating the DDL for creating a
a varchar_casesensitive/varchar_ignorecase.
|
(package private) static int |
DEFAULT_MAX_WIDTH
The default MAX-WIDTH for character fields if the attribute is not specified.
|
private static java.util.Map<java.lang.String,Dialect> |
dialectByJdbcType |
private static java.util.Map<java.lang.String,Dialect> |
knownDialects
Map of known/loaded dialect instances
|
private static CentralLogger |
log
Logger
|
(package private) static java.lang.String |
SCALE_TOK
Token used to mark a placeholder for the scale when generating the DDL for creating/altering a decimal
column in a table.
|
| Constructor and Description |
|---|
Dialect() |
| Modifier and Type | Method and Description |
|---|---|
void |
activateErrorHandler(java.sql.Connection conn)
Activate error handler at the database side.
|
abstract void |
addRtrimmedExpression(java.lang.String expr,
java.lang.StringBuilder sb)
Composes a rtrim equivalent call for a specified expression.
|
boolean |
allowBindParamsInRecursiveCTE()
Check if bind parameters in recursive CTEs are supported.
|
boolean |
allowDBUniqueCheck()
Determine if the
Dialect supports index validation (with the VALIDATE keyword). |
boolean |
allowSelectWildcard()
Check if this dialect allows the selection of fields using * wildcard.
|
void |
beforeDriverLoad()
Set any database parameters before, to be available when the database
driver is loaded.
|
abstract java.sql.Blob |
blobCreator(java.sql.Connection conn,
byte[] bytes)
Create a
Blob instance from the specified bytes. |
abstract java.lang.String |
buildRemoteURL(java.lang.String url,
Database database)
Build the URL to be used for a remote connection, based on the given URL and database.
|
java.lang.String |
checkErrorFn()
Get name of the checkError UDF.
|
void |
checkIndexConstraints(P2JIndex p2JIndex,
java.util.Map<java.lang.String,P2JField> fields)
If the dialect has some constraints about the index size, do the calculations and report any possible
error/warning when the database schema is set.
|
abstract java.sql.Clob |
clobCreator(java.sql.Connection conn,
java.lang.String value)
Create a
Clob instance from the specified value. |
int |
computeIndexKeySize(java.lang.Class<? extends BaseDataType> type,
java.lang.Object val)
Computes the size (in bytes) occupied by this value when stored as index-key in an index.
|
java.lang.Class<? extends com.mchange.v2.c3p0.AbstractConnectionCustomizer> |
connectionCustomizer(DatabaseConfig cfg)
Get c3p0 ConnectionCustomizer class for the dialect.
|
java.lang.String |
containsUdfName()
Return the name of the CONTAINS UDF
|
java.lang.Object |
createContext(Persistence persistence)
Create a data object, the purpose of which is specific to a particular
dialect implementation, to be stored as a context-local object.
|
abstract SequenceHandler |
createSequenceHandler(java.lang.String ldbName)
Creates and returns a
SequenceHandler for a database. |
static java.util.Map<java.lang.String,Dialect> |
dialects()
Get known dialects by name
|
ErrorManager.ErrorEntry |
errorEntry(java.lang.String message)
Create the error descriptor from the SQLException message
|
abstract boolean |
explicitSetCollation()
Check if the dialect needs to set an explicit collation during schema DDL generation.
|
abstract java.lang.String |
extractColumnName(java.lang.String expr)
Given a column expression as queried from database metadata, extract the root name of a
column.
|
abstract java.lang.String |
formatDate(date d)
Format a date object as a string which is appropriate for use in an SQL statement.
|
abstract void |
generateWordTablesDDLImpl(java.lang.String dbName,
java.io.PrintStream out,
java.lang.String eoln,
java.util.Collection<WordTable> wordTables)
Worker method for
generateTriggerDDLs(). |
java.lang.String |
getAddForeignKeyConstraintString(java.lang.String table,
java.lang.String fkName,
java.lang.String fkFields,
java.lang.String refTable,
java.lang.String refFields,
java.lang.String indent,
java.lang.String eoln)
Creates and returns a string which represent the
alter table statement for adding a new
foreign key constraint. |
abstract java.lang.String |
getAnalyzeString(java.lang.String table)
Construct and return a string which represents the
analyze or similar statements
for this dialect. |
java.lang.String |
getCatalogPattern(Database database)
Provides catalog matching pattern to load data correctly from JDBC.
|
java.lang.String |
getCodepage(java.sql.Connection conn)
Use the provided database connection to extract the codepage/CharSet used by the database and report it
back to the caller.
|
java.lang.String |
getCollation(java.sql.Connection conn)
Use the provided database connection to extract the collation used by the database and report it
back to the caller.
|
java.lang.String |
getComputedColumnFormula(java.lang.String colName,
boolean ignoreCase)
Returns the formula for character computed columns.
|
java.lang.String |
getComputedColumnPrefix(boolean caseSensitive)
Get the prefix, if any, which should be prepended to computed column and/or property names.
|
java.lang.String |
getComputedColumnString(java.lang.String name,
java.lang.String type,
int scale,
boolean cs)
Constructs and returns the declaration of a computed column based on its name, type, scale, and
case-sensitiveness.
|
java.lang.String |
getCreateIndexString(boolean unique)
Returns the beginning of the DDL statement for creating an index.
|
java.lang.String |
getCreateIndexString(boolean unique,
boolean softUnique)
Returns the beginning of the DDL statement for creating an index.
|
java.lang.String |
getCreateIndexString(P2JIndex index,
boolean unique,
boolean toFile)
Build the DDL to create an index based upon the specified definition.
|
abstract java.lang.String |
getCreateSequenceString(java.lang.String name)
Generate a DDL string which will create a global sequence.
|
java.lang.String |
getCreateSequenceString(java.lang.String name,
boolean isTemporary)
Generate a DDL string which will create a global sequence.
|
abstract java.lang.String |
getCreateSequenceString(java.lang.String name,
long start)
Generate a DDL string which will create a global sequence with the given starting value.
|
abstract java.lang.String |
getCreateSequenceString(java.lang.String name,
java.lang.Long init,
java.lang.Long increment,
java.lang.Long minVal,
java.lang.Long maxVal,
java.lang.Boolean cycle)
Generate a DDL string which will create a sequence with given properties.
|
java.lang.String |
getCreateTableString()
Returns the beginning of the DDL statement for creating a permanent table.
|
abstract java.lang.String |
getCreateTemporaryTablePostfix(boolean noUndo)
Return the ending of the DDL statement that creates a temporary table.
|
abstract java.lang.String |
getCreateTemporaryTableString(boolean ifNotExist)
Return the beginning of the DDL statement that creates a temporary table.
|
java.util.List<java.lang.String> |
getDatabasePrepareStatements(Database database)
Get a list of database prepare DDL statements.
|
java.lang.Long |
getDecimals(java.lang.String type,
java.lang.String decimals,
java.lang.String comment)
Get decimals value for types that support it.
|
abstract java.lang.String |
getDelimiter()
Get the statement delimiter for this dialect.
|
static Dialect |
getDialect(Database database)
Get the instance of a concrete subclass of this class which is associated with the given
database.
|
static Dialect |
getDialect(Settings settings)
Get the instance of a concrete subclass of this class, as specified in the given settings.
|
static Dialect |
getDialect(java.lang.String jdbcType)
Get the instance of a concrete subclass of this class which is associated with the given
JDBC database type.
|
abstract java.lang.String |
getDriverClassName()
Get the name of the JDBC driver class associated with this dialect.
|
abstract java.lang.String |
getDropIndexString(boolean ifExists,
java.lang.String idxName,
java.lang.String tableName)
Obtain a DDL statement which drops a SQL index.
|
abstract java.lang.String |
getDropIndexString(P2JIndex index)
Build the DDL to drop an index based upon the specified definition.
|
abstract java.lang.String |
getDropSequenceString(java.lang.String name)
Generate a DDL string which will drop a sequence.
|
abstract java.lang.String |
getDropTableString(boolean ifExists,
java.lang.String tableName)
Obtain a DDL statement which drops a SQL table.
|
java.sql.Date |
getHighDate()
Retrieve the latest possible date value which is valid for the backing database.
|
int |
getIndexLengthLimit()
Some dialects have constraints about the maximum size of fields that compose an index.
|
java.lang.String |
getInvisibleSpecificator()
Return a string which marks that a column is computed, so it should be marked as invisible
to allow implicit skipping of it when using wildcard selection (*) or direct access.
|
abstract java.lang.String |
getJdbcDatabaseType()
Get the name of the JDBC database type (as in JBC URL).
|
java.lang.String |
getLimitString(java.lang.String sql,
int offset,
int limit)
Get the limit string for the given limit and offset.
|
java.sql.Date |
getLowDate()
Retrieve the earliest possible date value which is valid for the backing database.
|
int |
getMaxEntriesInSelect()
Returns the max numbers of fields selected that the dialect can allow without throwing an error.
|
int |
getMaxParameterCount()
Obtain the number of parameters a query of this dialect is allowed by the SQL server.
|
abstract java.lang.String |
getProcessedCharacterColumnName(java.lang.String name,
boolean ignoreCase)
Adjust a character column name appropriate to this dialect, such that it
can be inserted into an index.
|
java.lang.String |
getSchemaPattern(Database database)
Provides schema matching pattern to load data correctly from JDBC.
|
abstract ScriptRunner |
getScriptRunner()
Get a ScriptRunner instance for the dialect.
|
java.lang.String |
getSequenceCurrValString()
Generate the appropriate select statement to retrieve the current value of a sequence.
|
abstract java.lang.String |
getSequenceCurrValString(java.lang.String sequenceName)
Generate the appropriate select statement to retrieve the current value of a sequence.
|
abstract java.lang.String |
getSequenceNextValString(java.lang.String sequenceName)
Generate the appropriate select statement to retrieve the next value of a sequence.
|
abstract java.lang.String |
getSequencePrefetchString(java.lang.String sequenceName)
Generate the appropriate select statement to pre-fetch multiple, ascending values from a sequence.
|
abstract java.lang.String |
getSequenceSetValString()
Generate the appropriate select statement to reset the value of a sequence.
|
abstract java.lang.String |
getSequenceSetValString(java.lang.String sequenceName)
Generate the appropriate select statement to reset the value of a sequence.
|
abstract java.lang.String |
getSequenceSetValString(java.lang.String sequenceName,
long newVal)
Generate the appropriate select statement to reset the value of a sequence.
|
java.lang.String |
getSequenceSQL(Database database)
Provides SQL to load sequences.
|
java.lang.String |
getSpecificTypeAsString(FqlType type)
Converts and return the specified
FqlType to a string representation which can be used in a
SQL query (cast or other construct). |
java.lang.String |
getSqlIndexName(P2JIndex index)
Obtain the name of an index.
|
java.lang.String |
getSqlMappedType(java.lang.Class<?> fwdType,
int scale,
java.lang.Boolean caseSensitive)
Get the SQL mapping for a specific FWD data type.
|
java.lang.String |
getSqlMappedType(java.lang.String fwdType,
int scale,
java.lang.Boolean caseSensitive)
Get the SQL mapping for a specific FWD data type.
|
abstract int |
getSyntheticIndexSize(boolean unique)
Returns the size of the synthetic part of the index.
|
abstract boolean |
hasFullSequenceSupport()
Returns
true if this dialect fully support the sequences as 4GL language (most important:
bounded values, cycle). |
abstract java.lang.String |
id()
Get dialect id.
|
java.lang.String |
initErrorFn()
Get name of the initError UDF.
|
abstract boolean |
injectComputedColumns()
Report whether the computed columns should be injected on table creating.
|
abstract void |
inlineLimit(boolean on)
Enable/disable limit clause inlining.
|
boolean |
isAutoCi()
Returns
true if the dialect handles case-insensitive compare
operations for case-insensitive character columns |
boolean |
isAutoRtrim()
Returns
true if the dialect handles automatically rtrimming for
character columns. |
abstract boolean |
isCaseInsensitiveColumn(java.lang.String name)
Report whether the given column name represents an alias or an expression which indicates
the column is case insensitive.
|
boolean |
isComputedColumn(java.lang.String name)
Report whether the given column name represents an alias or an expression which indicates
the column is computed.
|
abstract boolean |
isConnectionError(java.lang.Exception exc)
Given an exception, this method will check if it indicates a database connectivity error.
|
abstract boolean |
isMetadataSortAsc(java.lang.String value)
Check if the given value is a descending clause for a column index.
|
abstract boolean |
isMetadataSortDesc(java.lang.String value)
Check if the given value is an ascending clause for a column index.
|
abstract boolean |
isNativeUDFsSupported()
Check if native UDFs are supported for the dialect
|
abstract boolean |
isQueryRangeParameterInlined()
Indicate whether a query parameter which is part of a range check should
be inlined into the where clause, or whether it should be substituted
into a prepared statement.
|
boolean |
isUdfContains(java.lang.String name)
Check if the provided name is the name of the CONTAINS UDF
|
boolean |
isUdfOriginatedError(java.sql.SQLException e)
Check if the exception was caused by an error in UDF.
|
boolean |
isUdfOriginatedWarning(java.sql.SQLException e)
Check if the exception was caused by a warning in UDF.
|
abstract boolean |
isUniqueConstraintViolation(java.sql.SQLException sqle)
Checks if the SQLState of the SQLException matches the dialect specific UNIQUE_VIOLATION
code.
|
abstract boolean |
needsComputedColumns()
Indicate whether this dialect requires computed columns to participate
within index definitions, instead of embedded expressions.
|
int |
orderByNulls(java.lang.StringBuilder sb,
java.lang.String expression,
java.lang.String field,
boolean asc,
boolean forceAsc)
Determine if the sort component or index needs to be augmented with a NULLS FIRST/LAST option and
add the required expression(s) as needed by this dialect.
|
void |
postTransaction(Persistence persistence,
java.lang.Object context,
boolean rollback)
A dialect-specific callback hook which is invoked by the persistence runtime framework
after a transaction is complete.
|
boolean |
preferDisjunctiveForm()
Returns
true if the dialect handles the optimization of an augmented construct
which is resulted from comparing exactly two character fields. |
abstract java.lang.String |
prepareMetadataParameter(java.lang.String param)
Prepare the given metadata query parameter.
|
void |
preparePermanentDatabase(Database db)
Prepare the specified database by creating all necessary function aliases and setting global parameters.
|
abstract java.lang.String |
processMetadataResult(java.lang.String value)
Process the given metadata query result.
|
java.lang.String |
quote(java.lang.String expr)
Apply dialect-specific quoting.
|
abstract boolean |
requiresExplicitCastInsideTernary()
Determines whether substitution parameters should be explicitly casted
to their datatypes inside "then ? else ?" statement.
|
void |
resetErrorHandler(java.sql.Connection conn)
Reset error handler at the database side.
|
boolean |
resolveBooleanConstant(java.lang.String text)
Resolve the given text to a boolean value.
|
abstract ScriptSplitter |
scriptSplitter()
Get the splitter for DDL scripts.
|
abstract boolean |
supportsBooleanDatatype()
Indicates whether this dialect supports boolean datatype.
|
abstract boolean |
supportsFunctionOverloading()
Indicate whether this dialect natively supports the overloading of user
defined functions by parameter number and data type.
|
boolean |
supportsLazyQueryResultsMode()
Determine if the
Dialect supports queries executed in a lazy manner. |
boolean |
supportsVariableLimit()
Indicate whether a variable limit is supported by this dialect.
|
ParmType |
translateToParmType(java.lang.String type,
java.lang.String comment)
Translation from database column type to
ParmType. |
java.lang.String |
udfSchema()
Get UDF schema name (if applicable).
|
boolean |
useCTE4Contains()
Check if Common Table Expressions should be used for converted CONTAINS operator
|
boolean |
useMixedNode4Contains()
Check if mixed mode re-write should be used for converted CONTAINS operator
|
boolean |
useNullEquality()
Returns
true if the dialect handles null equality. |
abstract boolean |
useUdf4Contains()
Check if UDF should be used for converted CONTAINS operator
|
abstract boolean |
useWordTables()
Check if word tables should be used for converted CONTAINS operator
|
java.util.Optional<Dialect.WeightAggregator> |
weightAggregator()
Get the WeightAggregator instance for the dialect if defined
|
static final java.lang.String SCALE_TOK
static final java.lang.String CASE_TYPE_TOK
static final int DEFAULT_MAX_WIDTH
private static final CentralLogger log
private static final java.util.Map<java.lang.String,Dialect> knownDialects
private static final java.util.Map<java.lang.String,Dialect> dialectByJdbcType
public static Dialect getDialect(java.lang.String jdbcType)
jdbcType - Database jdbc type.public static Dialect getDialect(Database database)
There is one instance per subclass type; they are stateless and shared.
database - Database identifier.null if no dialect has
been configured for the database.public static java.util.Map<java.lang.String,Dialect> dialects()
public static Dialect getDialect(Settings settings)
null is returned.
There is one instance per subclass type; they are stateless and shared.
settings - Settings object which should contain a dialect entry.null.public abstract ScriptSplitter scriptSplitter()
public abstract ScriptRunner getScriptRunner()
public abstract java.sql.Blob blobCreator(java.sql.Connection conn,
byte[] bytes)
Blob instance from the specified bytes.conn - The JDBC connection.bytes - The blob data.public abstract java.sql.Clob clobCreator(java.sql.Connection conn,
java.lang.String value)
Clob instance from the specified value.conn - The JDBC connection.value - The clob data.public abstract java.lang.String getDriverClassName()
public abstract java.lang.String getJdbcDatabaseType()
public abstract java.lang.String id()
public abstract boolean useUdf4Contains()
true if UDF should be used for converted CONTAINS operatorpublic abstract boolean useWordTables()
true if tables should be used for converted CONTAINS operatorpublic abstract boolean isNativeUDFsSupported()
true if native UDFs are supported for the dialectpublic java.lang.String udfSchema()
public java.lang.String checkErrorFn()
public java.lang.String initErrorFn()
public boolean isUdfOriginatedError(java.sql.SQLException e)
e - the exception in questiontrue if the exception was caused by error in UDF.public boolean isUdfOriginatedWarning(java.sql.SQLException e)
e - the exception in questiontrue if the exception was caused by error in UDF.public ErrorManager.ErrorEntry errorEntry(java.lang.String message)
message - SQLException messagepublic boolean useCTE4Contains()
true if Common Table Expressions should be used for converted CONTAINS operatorpublic boolean useMixedNode4Contains()
true if mixed mode re-write should be usedpublic boolean isUdfContains(java.lang.String name)
name - name to be checkedtrue if the provided name is the name of the CONTAINS UDFpublic java.lang.String containsUdfName()
public java.lang.Class<? extends com.mchange.v2.c3p0.AbstractConnectionCustomizer> connectionCustomizer(DatabaseConfig cfg)
cfg - Database configuration.public void activateErrorHandler(java.sql.Connection conn)
throws java.sql.SQLException
conn - Database connectionjava.sql.SQLException - on error.public void resetErrorHandler(java.sql.Connection conn)
throws java.sql.SQLException
conn - Database connectionjava.sql.SQLException - on error.public abstract void generateWordTablesDDLImpl(java.lang.String dbName,
java.io.PrintStream out,
java.lang.String eoln,
java.util.Collection<WordTable> wordTables)
generateTriggerDDLs(). It generates the DDLs needed to create all
triggers in a database with a specific schema and using a certain dialect.dbName - The target schema.out - The PrintStream used for output.eoln - OS-specific end of line terminator.wordTables - word tables by namepublic java.lang.Object createContext(Persistence persistence)
Since the context-local data is specific to a particular dialect
implementation, it is optional. Dialect implementations which do not
have a need for this data should simply return null.
persistence - Provider of persistence services.null.public void postTransaction(Persistence persistence, java.lang.Object context, boolean rollback) throws PersistenceException
Default implementation does nothing.
persistence - Provider of persistence services.context - Optional, context-local data created previously by createContext(com.goldencode.p2j.persist.Persistence).rollback - true if transaction ended with a rollback;
false if transaction ended with a commit.PersistenceException - if any persistence-related error occurs.public java.sql.Date getLowDate()
null to indicate no
particular restriction.public java.sql.Date getHighDate()
null to indicate no
particular restriction.public abstract java.lang.String formatDate(date d)
d - Date to be formatted as a string.public abstract java.lang.String extractColumnName(java.lang.String expr)
upper(rtrim("key"::text))
We are interested only in the key root name, so we strip away the upper()
and rtrim() functions, the double quotes, and the ::text suffix.expr - Expression containing column name as natively represented by
the database dialect.public abstract java.lang.String getProcessedCharacterColumnName(java.lang.String name,
boolean ignoreCase)
name - Base column name.ignoreCase - true to cause case to be ignored, else false.public abstract boolean isCaseInsensitiveColumn(java.lang.String name)
name is
already determined to be the appropriate data type for textual data.name - Column name, alias, or expression.true if name represents case-insensitive data.public boolean isComputedColumn(java.lang.String name)
name is already
determined to be the appropriate data type for textual data.name - Column name, alias, or expression.true if name represents a computed column. Default implementation
returns false.public abstract boolean needsComputedColumns()
true to indicate computed columns are required;
false if the backing database can embed an
expression within an index definition.public java.lang.String getComputedColumnPrefix(boolean caseSensitive)
caseSensitive - true if this is a character field was declared with
CASE-SENSITIVE attribute. In each case the column name will be
name-decorated differently.needsComputedColumns()public abstract boolean supportsFunctionOverloading()
true if the backing database natively supports
overloading, else false.public abstract boolean supportsBooleanDatatype()
true and false literals;
true if the above mentioned items are supported or false if they
are handled by a replacement datatype (integer).public abstract java.lang.String getCreateSequenceString(java.lang.String name)
name - Sequence name.null if not supported.public java.lang.String getCreateSequenceString(java.lang.String name,
boolean isTemporary)
name - Sequence name.isTemporary - If the sequence should be temporary or not.null if not supported.public abstract java.lang.String getCreateSequenceString(java.lang.String name,
long start)
name - Sequence name.start - Sequence starting value.null if not supported.public abstract java.lang.String getCreateSequenceString(java.lang.String name,
java.lang.Long init,
java.lang.Long increment,
java.lang.Long minVal,
java.lang.Long maxVal,
java.lang.Boolean cycle)
name - Sequence name. Mandatory not null.init - Sequence starting value. Mandatory not null.increment - Sequence incrementing value. Mandatory not null.minVal - Sequence minimum value. Optional.maxVal - Sequence maximum value. Optional.cycle - Sequence cycling property. Optional, if missing assumed not cycling.null if not supported.public abstract java.lang.String getDropSequenceString(java.lang.String name)
name - The name of the sequence to be dropped.null if not supported.public abstract java.lang.String getSequenceSetValString(java.lang.String sequenceName,
long newVal)
sequenceName - The name of the sequence.newVal - The new value to be set.null
if not supported.public abstract java.lang.String getSequenceSetValString(java.lang.String sequenceName)
sequenceName - The name of the sequence.null
if not supported.public abstract java.lang.String getSequenceSetValString()
null
if not supported.public abstract java.lang.String getSequenceNextValString(java.lang.String sequenceName)
sequenceName - The name of the sequence to be queried.null if not supported.public abstract java.lang.String getSequenceCurrValString(java.lang.String sequenceName)
sequenceName - The name of the sequence to be queried.null if not supported.public java.lang.String getSequenceCurrValString()
null if not supported.public abstract boolean hasFullSequenceSupport()
true if this dialect fully support the sequences as 4GL language (most important:
bounded values, cycle). If not fully supported, additional code is needed in P2J sequence class
implementation to fix this.true if this dialect fully support 4GL sequencespublic abstract java.lang.String getSequencePrefetchString(java.lang.String sequenceName)
sequenceName - The name of the sequence from which the values are to be retrieved.null if this feature is not supported by the
dialect.public abstract boolean isConnectionError(java.lang.Exception exc)
exc - The exception to be checked.true if the exception indicates a database connectivity error.public abstract boolean isQueryRangeParameterInlined()
where value ≥ ? and id = ?
along with respective substitution parameters of 45 and 100, the
inlined version would read:
where value ≥ 45 and id = ?
Only the id substitution parameter of 100 would be
substituted into the prepared statement.
Inlining in such a way can give some database dialects the opportunity to choose a better query plan, than if the parameter being tested with a range check were to be substituted at statement execution time.
Note: this serves as a hint which may be overridden by runtime logic or other configuration settings.
true to inline range check parameters;
false to use normal parameter substitution.public abstract void inlineLimit(boolean on)
Dialects are free to treat this method as a hint.
on - true to enable inlining; false to
disable it.public abstract boolean requiresExplicitCastInsideTernary()
true if they should be casted.public boolean allowBindParamsInRecursiveCTE()
true if bind parameters in recursive CTEs are supported.public java.lang.String getLimitString(java.lang.String sql,
int offset,
int limit)
sql - Base select statement SQL without the limit/offset clause.offset - Starting offset.limit - Number of records to return.public boolean supportsVariableLimit()
false; should be overridden by dialects which support a variable (i.e.,
not inlined) limit string.public boolean resolveBooleanConstant(java.lang.String text)
text matches the strings "true" or
"1" case-insensitively, the result is true. Subclasses with more esoteric mappings may override
this method.text - A potential representation of a boolean constant.true if the given constant string represents boolean true, else false.public abstract java.lang.String getDropIndexString(P2JIndex index)
index - Definition of the index to be dropped.public java.lang.String getCreateIndexString(P2JIndex index, boolean unique, boolean toFile)
It is expected that this method is NOT used at runtime, as it has a dependency on conversion project configuration being available.
index - Definition of the index to be created.unique - If true, create the index as a unique index, otherwise omit the unique
constraint.toFile - true if the string will be output to a file. Otherwise it will be directly
submitted via JDBC.
TODO: this parameter seems to be unused. Drop it?public boolean isAutoRtrim()
true if the dialect handles automatically rtrimming for
character columns.public boolean useNullEquality()
true if the dialect handles null equality.
This is visible when doing null == null, which logically should return true,
but not all dialects support this condition.true if the dialect permits null equality.public boolean isAutoCi()
true if the dialect handles case-insensitive compare
operations for case-insensitive character columnspublic boolean preferDisjunctiveForm()
true if the dialect handles the optimization of an augmented construct
which is resulted from comparing exactly two character fields.public java.lang.String getComputedColumnFormula(java.lang.String colName,
boolean ignoreCase)
colName - The base column name.ignoreCase - true if this is a char field which has the "ignore case" flag set.null if the dialect does not support
computed columns.public java.lang.String getInvisibleSpecificator()
null means that no such
specificator is supported.public abstract java.lang.String prepareMetadataParameter(java.lang.String param)
param - The metadata query parameter.public abstract java.lang.String processMetadataResult(java.lang.String value)
value - The metadata query result.public abstract boolean isMetadataSortDesc(java.lang.String value)
value - The value to be checked.true if the value is the "ascending" clause.public abstract boolean isMetadataSortAsc(java.lang.String value)
value - The value to be checked.true if the value is the "descending" clause.public java.util.List<java.lang.String> getDatabasePrepareStatements(Database database)
database - The database which needs to be prepared.public abstract boolean explicitSetCollation()
true if the collation needs to be explicitly set.public abstract java.lang.String getDelimiter()
public void beforeDriverLoad()
public abstract java.lang.String buildRemoteURL(java.lang.String url,
Database database)
throws PersistenceException
url - The URL as received from the remote server.database - The database to which this URL belongs.PersistenceException - if the specified connection URL is invalid.public abstract SequenceHandler createSequenceHandler(java.lang.String ldbName)
SequenceHandler for a database.ldbName - The logical name of the database to create the SequenceHandler for.SequenceHandler for respective database.public abstract boolean injectComputedColumns()
true if the computed columns should be injected on table creating
else false.public abstract boolean isUniqueConstraintViolation(java.sql.SQLException sqle)
sqle - The SQLException that is causing the unique constraint violation.true if the SQLState matches the dialect specific code for
UNIQUE_VIOLATION, false otherwise.public java.lang.String getComputedColumnString(java.lang.String name,
java.lang.String type,
int scale,
boolean cs)
name - The original column name.type - The original column type.scale - The optional scale, if needed.cs - The case-sensitiveness.null if not needed.public java.lang.String quote(java.lang.String expr)
expr - String expression.public int getIndexLengthLimit()
public int computeIndexKeySize(java.lang.Class<? extends BaseDataType> type, java.lang.Object val)
getIndexLengthLimit() returns
positive values.
If this dialect does not have index-size constraints then this method does not need to be
overridden.type - The type to be analyzed.val - The actual value. Except for the char datatype, only the type of value
is used, the actual value is not needed to determine the size occupied by the
value as index-key.public abstract int getSyntheticIndexSize(boolean unique)
id
of the record may be additionally added to an index to add custom properties (eg uniqueness)
but other fields could be added. This part of the index is not visible using index
reflection routines from IndexHelper. The synthetic components may differ
between unique and non-unique indexes.unique - true if the index is uniquepublic abstract void addRtrimmedExpression(java.lang.String expr,
java.lang.StringBuilder sb)
rtrim(expr)
The rtrim-med expression is appended to the string builder.
The return value (the number of occurrences of the initial expr added to sb)
should be use by caller to count the number of possible parameters from a query.expr - The expression to be rtrim -med. It's up to the caller if it is
a qualified field or not or any other kind of character-type expression.sb - The StringBuilder to append the trimmed field to.public int getMaxParameterCount()
public java.lang.String getCreateTableString()
public abstract java.lang.String getCreateTemporaryTableString(boolean ifNotExist)
ifNotExist - If true a dialect-specific, optional if not exist clause is added.public abstract java.lang.String getCreateTemporaryTablePostfix(boolean noUndo)
noUndo - If true, this function will return the keyword specific to no-undo temp-tables.public java.lang.String getCreateIndexString(boolean unique)
unique - true for unique indexes.public java.lang.String getCreateIndexString(boolean unique,
boolean softUnique)
unique - true for unique indexes.softUnique - true for soft-unique indexes.public abstract java.lang.String getDropIndexString(boolean ifExists,
java.lang.String idxName,
java.lang.String tableName)
ifExists - Flag that requires that the DDL include an optional IF EXIST clause.idxName - The name of the index to be dropped by this DDL.tableName - The name of the table to which the index belongs to. (Optional, is needed by the dialect).public abstract java.lang.String getDropTableString(boolean ifExists,
java.lang.String tableName)
ifExists - Flag that requires that the DDL include an optional IF EXIST clause.tableName - The name of the table to be dropped by this DDL.public java.lang.String getSpecificTypeAsString(FqlType type)
FqlType to a string representation which can be used in a
SQL query (cast or other construct).type - The type to be converted to string.public java.lang.String getSqlMappedType(java.lang.Class<?> fwdType,
int scale,
java.lang.Boolean caseSensitive)
fwdType - The FWD type.scale - Optional scale parameter (for decimal data type).fwdType.public java.lang.String getSqlMappedType(java.lang.String fwdType,
int scale,
java.lang.Boolean caseSensitive)
fwdType - The class name of the FWD datatype.scale - Optional scale parameter (for decimal data type).fwdType.public abstract java.lang.String getAnalyzeString(java.lang.String table)
analyze or similar statements
for this dialect. If the table is not null the statement will analyze only
the respective table. Otherwise, all the tables are analyzed.table - The name of the table to be analyzed. If null, all tables from the database
will be analyzed, if possible.analyze statement in the form requested null is returned.public int orderByNulls(java.lang.StringBuilder sb,
java.lang.String expression,
java.lang.String field,
boolean asc,
boolean forceAsc)
sb - The StringBuilder which contains the SQL statement to be built.expression - The field name (or expression) which is the current criterion to be augmented.field - The field name which is the base of the previous parameter (possible null, ignored here).asc - The sort direction.forceAsc - If true, force the insertion of the default asc direction.public java.util.Optional<Dialect.WeightAggregator> weightAggregator()
public ParmType translateToParmType(java.lang.String type, java.lang.String comment)
ParmType. This is a general implementation that will work
for common types used in FWD. For fine-tuning, you can override it in specific dialects.
TODO: should be abstracttype - column typecomment - comment with optional specification of typepublic java.lang.Long getDecimals(java.lang.String type,
java.lang.String decimals,
java.lang.String comment)
type - column typedecimals - decimals value as provided by the databasecomment - comment with optional metadatapublic java.lang.String getAddForeignKeyConstraintString(java.lang.String table,
java.lang.String fkName,
java.lang.String fkFields,
java.lang.String refTable,
java.lang.String refFields,
java.lang.String indent,
java.lang.String eoln)
alter table statement for adding a new
foreign key constraint.table - The table to be altered.fkName - The name of the constraint.fkFields - Comma separated names of the fields which make the reference to parent table.refTable - The parent / referred table.refFields - Comma separated names of the fields which uniquely identify the record in parent table.indent - The indentation for pretty print the result.eoln - OS-specific end of line terminator (if the result is a multiline).public java.lang.String getCatalogPattern(Database database)
database - database objectpublic java.lang.String getSchemaPattern(Database database)
database - database objectpublic boolean supportsLazyQueryResultsMode()
Dialect supports queries executed in a lazy manner.
Unless implemented, lazy queries are not supported.false
By default, lazy queries are not supported.public boolean allowDBUniqueCheck()
Dialect supports index validation (with the VALIDATE keyword).false
By default, VALIDATE is not supported.public java.lang.String getSequenceSQL(Database database)
database - database objectpublic void checkIndexConstraints(P2JIndex p2JIndex, java.util.Map<java.lang.String,P2JField> fields)
The default implementation does nothing.
p2JIndex - The index to be processed.fields - All table fields, mapped by their legacy name.public void preparePermanentDatabase(Database db) throws PersistenceException
The default implementation from Dialect does nothing.
db - Database to prepare.PersistenceException - if there is any error executing DDL.public java.lang.String getSqlIndexName(P2JIndex index)
index - The index structure.public boolean allowSelectWildcard()
true if we can use * as selection wildcard.public int getMaxEntriesInSelect()
public java.lang.String getCodepage(java.sql.Connection conn)
conn - The JDBC database connection to be used.public java.lang.String getCollation(java.sql.Connection conn)
conn - The JDBC database connection to be used.