public class MySQLEngine extends AbstractDbEngine implements DbEngine
Constructor and Description |
---|
MySQLEngine()
Create MySQLEngine.
|
Modifier and Type | Method and Description |
---|---|
boolean |
analyzeAfterBatchOperation()
Return true.
|
private void |
appendList(StringBuilder sb,
Collection<String> items) |
boolean |
caseInsensitiveComparison()
Returns TRUE.
|
String |
getAnalyzeTableSql(String catalog,
String schema,
String table)
Generate
ANALYZE TABLE <catalog>. |
String |
getApproximateRowCountSql(String catalog,
String schema,
String table)
Get an SQL statement that returns an approximate count for the number
of rows in the given table.
|
String |
getCaseSensitiveVarchar(int length)
Return
varchar(length) CHARACTER SET utf8 COLLATE utf8_bin . |
String |
getCatalogName(String catalog,
String schema)
Generates a catalog name by combining the catalog and
schema name (catalog_schema).
|
String |
getCreateForeignKeySql(String catalog,
String schema,
String table,
String name,
Set<String> columns,
String refTable,
Set<String> refColumns)
Generate
ALTER TABLE schema.table ADD CONSTRAINT name
FOREIGN KEY (columns) REFERERENCES refTable (refColumns) |
String |
getCreateIndexSql(String catalog,
String schema,
String table,
String name,
Set<String> columns,
boolean unique)
Generate
ALTER TABLE <catalog>. |
String |
getCreatePrimaryKeySql(String catalog,
String schema,
String table,
String name,
Set<String> columns)
Generate
ALTER TABLE catalog.table ADD PRIMARY KEY (columns) |
String |
getCreateSchemaSql(String catalog,
String schema)
Generate
CREATE SCHEMA <catalog> . |
String |
getDropForeignKeySql(String catalog,
String schema,
String table,
String name)
Generate
ALTER TABLE <catalog>. |
String |
getDropIndexSql(String catalog,
String schema,
String table,
String name,
boolean unique)
Generate
DROP INDEX <name> ON <catalog>. |
String |
getDropPrimaryKey(String catalog,
String schema,
String table,
String name)
Generate
ALTER TABLE catalog.table DROP PRIMARY KEY |
String |
getInsertAutoIncrementSql(PersistentClass pc)
Return a SQL fragment that can be used in an INSERT INTO statement
to generate an ID for new rows.
|
String |
getOptimizeTableSql(String catalog,
String schema,
String table)
Generate
OPTIMIZE TABLE <catalog>. |
String |
getQuotedName(String name)
Put quotes (`) around the name.
|
String |
getSchemaName(String catalog,
String schema)
Return null.
|
String |
inspectSchemaGenerationSQL(String sql,
Dialect dialect,
SchemaGenerator.Mode mode)
Fix "alter table ... drop constraint ..." statements that are generated
incorrectly by Hibernate.
|
String |
ln(String value)
Return
LOG(<value>) . |
String |
makeSafeCreateTable(String sql,
String catalog,
String schema,
String table)
Replace CREATE TABLE with CREATE TABLE IF NOT EXISTS...
|
String |
rlike(String value,
String regexp)
Return
<value> RLIKE <regexp> . |
boolean |
supportColumnAliasInGroupBy()
Returns TRUE.
|
boolean |
supportColumnAliasInHaving()
Returns TRUE.
|
boolean |
supportColumnAliasInOrderBy()
Returns TRUE.
|
boolean |
supportsColumnAliasInWhere()
Returns FALSE.
|
boolean |
useThetaJoin()
Always false.
|
abs, castToDate, checkForInvalidNumberOperation, exp, getMaxParametersInQuery, isValidColumnName, isValidName, isValidTableName, power, selectOrderByColumnsIfDistinct, useSavePointToContinueTransactionFromSqlFailure
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
abs, castToDate, checkForInvalidNumberOperation, exp, getMaxParametersInQuery, isValidColumnName, isValidTableName, power, selectOrderByColumnsIfDistinct, useSavePointToContinueTransactionFromSqlFailure
public boolean useThetaJoin()
useThetaJoin
in interface DbEngine
useThetaJoin
in class AbstractDbEngine
public String getCatalogName(String catalog, String schema)
getCatalogName
in interface DbEngine
getCatalogName
in class AbstractDbEngine
catalog
- The catalog name (always not null)schema
- The schema name (always not null)public String getSchemaName(String catalog, String schema)
getSchemaName
in interface DbEngine
getSchemaName
in class AbstractDbEngine
catalog
- The catalog name (always not null)schema
- The schema name (always not null)public String getCreateSchemaSql(String catalog, String schema)
CREATE SCHEMA <catalog>
.getCreateSchemaSql
in interface DbEngine
public String getCreateIndexSql(String catalog, String schema, String table, String name, Set<String> columns, boolean unique)
ALTER TABLE <catalog>.<table> ADD [UNIQUE]
INDEX <name> (<columns>)
.
The schema parameter is not supported.getCreateIndexSql
in interface DbEngine
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 notpublic String getDropIndexSql(String catalog, String schema, String table, String name, boolean unique)
DROP INDEX <name> ON <catalog>.<table>
.
The schema parameter is not supported.getDropIndexSql
in interface DbEngine
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 notpublic String getCreateForeignKeySql(String catalog, String schema, String table, String name, Set<String> columns, String refTable, Set<String> refColumns)
ALTER TABLE schema.table ADD CONSTRAINT name
FOREIGN KEY (columns) REFERERENCES refTable (refColumns)
getCreateForeignKeySql
in interface DbEngine
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 keypublic String getDropForeignKeySql(String catalog, String schema, String table, String name)
ALTER TABLE <catalog>.<table> DROP FOREIGN KEY <name>
getDropForeignKeySql
in interface DbEngine
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 keypublic String getCreatePrimaryKeySql(String catalog, String schema, String table, String name, Set<String> columns)
ALTER TABLE catalog.table ADD PRIMARY KEY (columns)
getCreatePrimaryKeySql
in interface DbEngine
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 keypublic String getDropPrimaryKey(String catalog, String schema, String table, String name)
ALTER TABLE catalog.table DROP PRIMARY KEY
getDropPrimaryKey
in interface DbEngine
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 keypublic String getInsertAutoIncrementSql(PersistentClass pc)
DbEngine
getInsertAutoIncrementSql
in interface DbEngine
pc
- The persistent classpublic String inspectSchemaGenerationSQL(String sql, Dialect dialect, SchemaGenerator.Mode mode)
inspectSchemaGenerationSQL
in interface DbEngine
inspectSchemaGenerationSQL
in class AbstractDbEngine
sql
- The original SQL statment as generated by Hibernatedialect
- The Hibernate dialect currently in usemode
- The installation modepublic boolean analyzeAfterBatchOperation()
analyzeAfterBatchOperation
in interface DbEngine
public String getOptimizeTableSql(String catalog, String schema, String table)
OPTIMIZE TABLE <catalog>.<table>
.
The schema parameter is not supported.getOptimizeTableSql
in interface DbEngine
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 optimizeDbEngine.getAnalyzeTableSql(String, String, String)
public String getAnalyzeTableSql(String catalog, String schema, String table)
ANALYZE TABLE <catalog>.<table>
.
The schema parameter is not supported.getAnalyzeTableSql
in interface DbEngine
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 analyzeDbEngine.getOptimizeTableSql(String, String, String)
public String makeSafeCreateTable(String sql, String catalog, String schema, String table)
makeSafeCreateTable
in interface DbEngine
makeSafeCreateTable
in class AbstractDbEngine
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 createdpublic boolean caseInsensitiveComparison()
caseInsensitiveComparison
in interface DbEngine
public boolean supportsColumnAliasInWhere()
supportsColumnAliasInWhere
in interface DbEngine
supportsColumnAliasInWhere
in class AbstractDbEngine
public boolean supportColumnAliasInOrderBy()
supportColumnAliasInOrderBy
in interface DbEngine
supportColumnAliasInOrderBy
in class AbstractDbEngine
public boolean supportColumnAliasInGroupBy()
supportColumnAliasInGroupBy
in interface DbEngine
supportColumnAliasInGroupBy
in class AbstractDbEngine
public boolean supportColumnAliasInHaving()
supportColumnAliasInHaving
in interface DbEngine
supportColumnAliasInHaving
in class AbstractDbEngine
public String ln(String value)
LOG(<value>)
.ln
in interface DbEngine
ln
in class AbstractDbEngine
value
- The value to take the logarithm ofpublic String rlike(String value, String regexp)
<value> RLIKE <regexp>
.rlike
in interface DbEngine
rlike
in class AbstractDbEngine
value
- The left valueregexp
- The regular expression as a stringpublic String getCaseSensitiveVarchar(int length)
varchar(length) CHARACTER SET utf8 COLLATE utf8_bin
.getCaseSensitiveVarchar
in interface DbEngine
getCaseSensitiveVarchar
in class AbstractDbEngine
length
- The maximum length that needs to be stored in the columnpublic String getQuotedName(String name)
getQuotedName
in interface DbEngine
getQuotedName
in class AbstractDbEngine
name
- The name of an object in the databasepublic String getApproximateRowCountSql(String catalog, String schema, String table)
DbEngine
getApproximateRowCountSql
in interface DbEngine
getApproximateRowCountSql
in class AbstractDbEngine
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 tableprivate void appendList(StringBuilder sb, Collection<String> items)