public interface DbEngine
Dialect
objects.EngineFactory.createEngine(Dialect)
Modifier and Type | Method and Description |
---|---|
java.lang.String |
abs(java.lang.String value)
Get the function call that takes the absolute of a value.
|
boolean |
analyzeAfterBatchOperation()
If TRUE, a batcher that inserts, updates or delets a lot
of rows in a table should execute the SQL returned by
getAnalyzeTableSql(String, String, String) for that table. |
boolean |
caseInsensitiveComparison()
If the database does case sensitive or case insensitive string
comparison in expressions.
|
java.lang.String |
castToDate(java.lang.String value)
Get a function that casts a date/timestamp to a date (eg. no time
should be included in the result).
|
boolean |
checkForInvalidNumberOperation()
If we need to check for invalid arguments to numerical
functions to avoid exceptions from the database.
|
boolean |
dropForeignKeysUsedInIndex()
When dropping an index, must foreign keys that uses the same columns also be
dropped (before dropping the index)?
|
java.lang.String |
exp(java.lang.String value)
Get the function call that calculates the exponential of a value.
|
java.lang.String |
getAnalyzeTableSql(java.lang.String catalog,
java.lang.String schema,
java.lang.String table)
Generate SQL to update the index statistics for a table.
|
java.lang.String |
getApproximateRowCountSql(java.lang.String catalog,
java.lang.String schema,
java.lang.String table)
Get an SQL statement that returns an approximate count for the number
of rows in the given table.
|
java.lang.String |
getCaseSensitiveVarchar(int length)
Generate a column declaration that creates a case-sensitive
variable-length string column type.
|
java.lang.String |
getCatalogName(java.lang.String catalog,
java.lang.String schema)
Get the catalog name to use for referencing the given catalog/schema
pair.
|
java.lang.String |
getCreateForeignKeySql(java.lang.String catalog,
java.lang.String schema,
java.lang.String table,
java.lang.String name,
java.util.Set<java.lang.String> columns,
java.lang.String refTable,
java.util.Set<java.lang.String> refColumns)
Generates SQL that creates a foreign key constraint between two tables.
|
java.lang.String |
getCreateIndexSql(java.lang.String catalog,
java.lang.String schema,
java.lang.String table,
java.lang.String name,
java.util.Set<java.lang.String> columns,
boolean unique)
Generate SQL to create an index.
|
java.lang.String |
getCreatePartialIndexSql(java.lang.String catalog,
java.lang.String schema,
java.lang.String table,
java.lang.String name,
java.util.Set<java.lang.String> columns,
java.lang.String condition)
Generate SQL to create a partial index.
|
java.lang.String |
getCreatePrimaryKeySql(java.lang.String catalog,
java.lang.String schema,
java.lang.String table,
java.lang.String name,
java.util.Set<java.lang.String> columns)
Generate SQL to create a primary key for a table.
|
java.lang.String |
getCreateSchemaSql(java.lang.String catalog,
java.lang.String schema)
Generate an SQL statement to create the given schema.
|
java.lang.String |
getDropForeignKeySql(java.lang.String catalog,
java.lang.String schema,
java.lang.String table,
java.lang.String name)
Generate SQL to drop a foreign key constraint.
|
java.lang.String |
getDropIndexSql(java.lang.String catalog,
java.lang.String schema,
java.lang.String table,
java.lang.String name,
boolean unique)
Generate SQL to drop an index.
|
java.lang.String |
getDropPrimaryKey(java.lang.String catalog,
java.lang.String schema,
java.lang.String table,
java.lang.String name)
Generate SQL that drops the primary key from a table.
|
java.lang.String |
getInsertAutoIncrementSql(PersistentClass pc)
Return a SQL fragment that can be used in an INSERT INTO statement
to generate an ID for new rows.
|
int |
getMaxParametersInQuery()
Get the maximum number of parameters that can be used in a prepared
statement for a query.
|
java.lang.String |
getOptimizeTableSql(java.lang.String catalog,
java.lang.String schema,
java.lang.String table)
Generate SQL to optimize a table.
|
java.lang.String |
getQuotedName(java.lang.String name)
Quote the name with the database specific quote character.
|
java.lang.String |
getSchemaName(java.lang.String catalog,
java.lang.String schema)
Get the schema name to use for referencing the given catalog/schema
pair.
|
java.lang.String |
inspectSchemaGenerationSQL(java.lang.String sql,
Dialect dialect,
SchemaGenerator.Mode mode)
Let the DbEninge inspect a schema generation sql statment and
possible modify it before it is sent to the database.
|
boolean |
isValidColumnName(java.lang.String columnName)
Check if a given string is valid to be used as a column name in the
current database.
|
boolean |
isValidTableName(java.lang.String tableName)
Check if a given string is valid to be used as a table name in the
current database.
|
java.lang.String |
ln(java.lang.String value)
Get the function call that takes the natural logarithm
of a value.
|
java.lang.String |
makeSafeCreateTable(java.lang.String sql,
java.lang.String catalog,
java.lang.String schema,
java.lang.String table)
Create a "safe" CREATE TABLE query string that will not fail if the table already
exists.
|
java.lang.String |
power(java.lang.String base,
java.lang.String exponent)
Get the function call that calculates
base
raised to the power of exponent
For example: POW(base, value) |
java.lang.String |
rlike(java.lang.String value,
java.lang.String regexp)
Get a function/expression that matches the left value against
the right value which should be a regular expression.
|
boolean |
selectOrderByColumnsIfDistinct()
If the database requires that columns appearing in the
ORDER BY part of the query must also be part of the SELECT
list when using the DISTINCT keyword.
|
boolean |
supportColumnAliasInGroupBy()
If the current database supports column aliases in the group by part of
a query or not.
|
boolean |
supportColumnAliasInHaving()
If the current database supports column aliases in the order by part of
a query or not.
|
boolean |
supportColumnAliasInOrderBy()
If the current database supports column aliases in the order by part of
a query or not.
|
boolean |
supportsColumnAliasInWhere()
If the current database supports column aliases in the where part of
a query or not.
|
boolean |
useSavePointToContinueTransactionFromSqlFailure()
If the underlying database need to create a savepoint before executing
an SQL statement that results in an error in order to be able to
continue using the same transaction for other SQL queries.
|
boolean |
useThetaJoin()
If the database uses theta join or ansi join.
|
java.lang.String getQuotedName(java.lang.String name)
name
- The name of an object in the databaseboolean useThetaJoin()
java.lang.String getCatalogName(java.lang.String catalog, java.lang.String schema)
catalog
- The catalog name (always not null)schema
- The schema name (always not null)java.lang.String getSchemaName(java.lang.String catalog, java.lang.String schema)
catalog
- The catalog name (always not null)schema
- The schema name (always not null)java.lang.String getCreateSchemaSql(java.lang.String catalog, java.lang.String schema)
getCatalogName(String, String)
and getSchemaName(String, String)
.java.lang.String getCreateIndexSql(java.lang.String catalog, java.lang.String schema, java.lang.String table, java.lang.String name, java.util.Set<java.lang.String> columns, boolean unique)
catalog
- The name of the catalog (database) where the table is
located, or null if it is located in the current catalogschema
- The name of the schema where the table is located, or
null if is located in the current schematable
- The name of the tablename
- The name of the index to be createdcolumns
- The name of the columns in the indexunique
- If the index must contain unique values or notjava.lang.String getCreatePartialIndexSql(java.lang.String catalog, java.lang.String schema, java.lang.String table, java.lang.String name, java.util.Set<java.lang.String> columns, java.lang.String condition)
catalog
- The name of the catalog (database) where the table is
located, or null if it is located in the current catalogschema
- The name of the schema where the table is located, or
null if is located in the current schematable
- The name of the tablename
- The name of the index to be createdcolumns
- The name of the columns in the indexcondition
- The condition that specifies which rows to include in the index.
Use '[' and ']' as placeholders for the open/close quote of the current dialect.java.lang.String getDropIndexSql(java.lang.String catalog, java.lang.String schema, java.lang.String table, java.lang.String name, boolean unique)
catalog
- The name of the catalog (database) where the table is
located, or null if it is located in the current catalogschema
- The name of the schema where the table is located, or
null if is located in the current schematable
- The name of the tablename
- The name of the indexunique
- If the index contains unique values or notboolean dropForeignKeysUsedInIndex()
java.lang.String getCreateForeignKeySql(java.lang.String catalog, java.lang.String schema, java.lang.String table, java.lang.String name, java.util.Set<java.lang.String> columns, java.lang.String refTable, java.util.Set<java.lang.String> refColumns)
catalog
- The name of the catalog (database) where the tables are
located, or null if it is located in the current catalogschema
- The name of the schema where the tables are located, or
null if is located in the current schematable
- The name of the foreign key tablename
- The name of the foreign keycolumns
- The columns that make up the foreign keyrefTable
- The table that is referenced by the foreign keyrefColumns
- The columns that are referenced by the foreign keyjava.lang.String getDropForeignKeySql(java.lang.String catalog, java.lang.String schema, java.lang.String table, java.lang.String name)
catalog
- The name of the catalog (database) where the table is
located, or null if it is located in the current catalogschema
- The name of the schema where the table is located, or
null if is located in the current schematable
- The name of the tablename
- The name of the foreign keyjava.lang.String getCreatePrimaryKeySql(java.lang.String catalog, java.lang.String schema, java.lang.String table, java.lang.String name, java.util.Set<java.lang.String> columns)
catalog
- The name of the catalog (database) where the table is
located, or null if it is located in the current catalogschema
- The name of the schema where the table is located, or
null if is located in the current schematable
- The name of the tablename
- The name of the primary keycolumns
- The name of the columns in the primary keyjava.lang.String getDropPrimaryKey(java.lang.String catalog, java.lang.String schema, java.lang.String table, java.lang.String name)
catalog
- The name of the catalog (database) where the table is
located, or null if it is located in the current catalogschema
- The name of the schema where the table is located, or
null if is located in the current schematable
- The name of the tablename
- The name of the primary keyjava.lang.String getInsertAutoIncrementSql(PersistentClass pc)
pc
- The persistent classboolean analyzeAfterBatchOperation()
getAnalyzeTableSql(String, String, String)
for that table.
Postgres, for example, almost always require that an analysis is run since subsequent queries otherwise may take a long time to execute if indexes can't be used properly.
java.lang.String getOptimizeTableSql(java.lang.String catalog, java.lang.String schema, java.lang.String table)
MySQL: OPTIMIZE TABLE <table> Postgres: VACCUUM <table>NOTE! The SQL returned by this method may impact the performance on the database. It is only intended to be executed when there is a need to clean up the database. How often this is needed depends on the database.
catalog
- The name of the catalog (database) where the table is
located, or null if it is located in the current catalogschema
- The name of the schema where the table is located, or
null if is located in the current schematable
- The name of the table to optimizegetAnalyzeTableSql(String, String, String)
java.lang.String getAnalyzeTableSql(java.lang.String catalog, java.lang.String schema, java.lang.String table)
MySQL: ANALYZE TABLE <table> Postgres: ANALYZE <table>NOTE! The SQL returned by this method must be able to run within a transaction and from multiple transactions on the same table at the same time. If no such SQL statement exists null should be returned.
catalog
- The name of the catalog (database) where the table is
located, or null if it is located in the current catalogschema
- The name of the schema where the table is located, or
null if is located in the current schematable
- The name of the table to analyzegetOptimizeTableSql(String, String, String)
java.lang.String makeSafeCreateTable(java.lang.String sql, java.lang.String catalog, java.lang.String schema, java.lang.String table)
sql
- The original SQLcatalog
- The name of the catalog (database) where the table is
being create, or null if it is located in the current catalogschema
- The name of the schema where the table is being created, or
null if is located in the current schematable
- The name of the table that is being createdboolean caseInsensitiveComparison()
boolean supportsColumnAliasInWhere()
SELECT tbl.blah as foo, ... FROM Table tbl WHERE foo = 2
If not supported the entire expression will be used again.
boolean supportColumnAliasInOrderBy()
SELECT tbl.blah as foo, ... FROM Table tbl ORDER BY foo
If not supported the entire expression will be used again.
boolean supportColumnAliasInGroupBy()
SELECT tbl.blah as foo, ... FROM Table tbl GROUP BY foo
If not supported the entire expression will be used again.
boolean supportColumnAliasInHaving()
SELECT count(tbl.blah) as foo, ... FROM Table tbl
GROUP BY ... HAVING foo = 2
If not supported the entire expression will be used again.
boolean selectOrderByColumnsIfDistinct()
boolean checkForInvalidNumberOperation()
CASE...WHEN
statement to the query for
Postgres. Example:
CASE WHEN denominator = 0 THEN null ELSE numerator / denominator
int getMaxParametersInQuery()
java.lang.String ln(java.lang.String value)
LN(value)
value
- The value to take the logarithm ofjava.lang.UnsupportedOperationException
- If the database doesn't support
logarithmsjava.lang.String abs(java.lang.String value)
ABS(value)
value
- The value to use in the calculationjava.lang.UnsupportedOperationException
- If the database doesn't support
this functionjava.lang.String exp(java.lang.String value)
EXP(value)
value
- The value to use in the calculationjava.lang.UnsupportedOperationException
- If the database doesn't support
this functionjava.lang.String power(java.lang.String base, java.lang.String exponent)
base
raised to the power of exponent
For example: POW(base, value)
base
- The base in the expressionexponent
- The exponent in the expressionjava.lang.UnsupportedOperationException
- If the database doesn't support
this functionjava.lang.String rlike(java.lang.String value, java.lang.String regexp)
value
- The left valueregexp
- The regular expression as a stringjava.lang.String castToDate(java.lang.String value)
value
- The value to castboolean isValidTableName(java.lang.String tableName)
tableName
- The string to checkboolean isValidColumnName(java.lang.String columnName)
columnName
- The string to checkjava.lang.String getCaseSensitiveVarchar(int length)
length
- The maximum length that needs to be stored in the columnjava.lang.String inspectSchemaGenerationSQL(java.lang.String sql, Dialect dialect, SchemaGenerator.Mode mode)
SchemaGenerator
class
when creating or updating a database.sql
- The original SQL statment as generated by Hibernatedialect
- The Hibernate dialect currently in usemode
- The installation modeboolean useSavePointToContinueTransactionFromSqlFailure()
java.lang.String getApproximateRowCountSql(java.lang.String catalog, java.lang.String schema, java.lang.String table)
catalog
- The name of the catalog (database) where the table is
located, or null if it is located in the current catalogschema
- The name of the schema where the table is located, or
null if is located in the current schematable
- The name of the table