@Service(value=Backend.class) public class MySql extends AbstractSql92Backend
| Modifier and Type | Field and Description |
|---|---|
static String |
SQL_LIMIT
LIMIT string.
|
static String |
SQL_LIMIT_PAR
LIMIT ? string.
|
static String |
SQL_OFFSET
OFFSET string.
|
static String |
SQL_OFFSET_PAR
OFFSET ? string.
|
SQL_COALESCE, SQL_FOR_UPDATEEMPTY_STRING, TYPE_BIGINT, TYPE_BIT, TYPE_BLOB, TYPE_BOOL, TYPE_BOOLEAN, TYPE_BYTE, TYPE_BYTEA, TYPE_CHAR_1, TYPE_DATE, TYPE_DATETIME, TYPE_DATETIME_YEAR_TO_SECOND, TYPE_DECIMAL, TYPE_DECIMAL_19, TYPE_DOUBLE, TYPE_FLOAT, TYPE_FLOAT4, TYPE_FLOAT8, TYPE_INT, TYPE_INT2, TYPE_INT4, TYPE_INT8, TYPE_INTEGER, TYPE_NCHAR_1, TYPE_NUMBER, TYPE_NUMBER_1, TYPE_NUMBER_10, TYPE_NUMBER_19, TYPE_NUMBER_5, TYPE_NVARCHAR, TYPE_NVARCHAR_MAX, TYPE_REAL, TYPE_SMALLFLOAT, TYPE_SMALLINT, TYPE_TEXT, TYPE_TIME, TYPE_TIMESTAMP, TYPE_TINYINT, TYPE_VARBINARY_MAX, TYPE_VARCHARSQL_ALLSTAR, SQL_AND, SQL_ANDNOT, SQL_COMMA, SQL_COMMA_PAR, SQL_DELETE, SQL_EQUAL, SQL_EQUAL_PAR, SQL_EQUAL_PAR_COMMA, SQL_EQUAL_ZERO, SQL_FROM, SQL_GREATER, SQL_GREATER_PAR, SQL_GREATEROREQUAL, SQL_GREATEROREQUAL_PAR, SQL_GROUPBY, SQL_INSERT_INTO, SQL_INSERT_VALUES, SQL_ISNOTNULL, SQL_ISNULL, SQL_LEFT_PARENTHESIS, SQL_LESS, SQL_LESS_PAR, SQL_LESSOREQUAL, SQL_LESSOREQUAL_PAR, SQL_LIKE, SQL_LIKE_PAR, SQL_MAX, SQL_MIN, SQL_NOT, SQL_NOTEQUAL, SQL_NOTEQUAL_PAR, SQL_NOTEQUAL_ZERO, SQL_NOTLIKE, SQL_NOTLIKE_PAR, SQL_OR, SQL_ORDERBY, SQL_ORNOT, SQL_PAR, SQL_PAR_COMMA, SQL_PLUS_ONE, SQL_RIGHT_PARENTHESIS, SQL_SELECT, SQL_SELECT_ALL_FROM, SQL_SET, SQL_SORTASC, SQL_SORTDESC, SQL_UPDATE, SQL_WHERE, SQL_WHEREALL, SQL_WHEREAND, SQL_WHERENOTHING, SQL_WHEREOR| Constructor and Description |
|---|
MySql() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
allowsExpressionsReferringToTablesBeingUpdated()
Determines whether backend allows expressions referring to tables being updated.
|
void |
buildSelectSql(StringBuilder sqlBuilder,
boolean writeLock,
int limit,
int offset)
Creates a select statement string from an inner sql string.
|
ColumnMetaData |
createColumnMetaData(TableMetaData tableMetaData)
Creates a column meta data instance.
|
protected String |
extractWhereClause(String sql,
int whereOffset)
Extracts the where clause from a given sql.
|
String |
getBackendId(Connection connection)
Determines the unique id or name used by the backend for a given connection.
|
String |
getDriverClassName()
Gets the JDBC driver class name.
|
int |
getMaxSize(SqlType sqlType)
Returns the maximum size for a given SQL-type.
|
DatabaseMetaData[] |
getMetaData(BackendInfo backendInfo)
Gets the metadata from the backend.
|
MigrationStrategy[] |
getMigrationStrategy(ColumnMetaData column,
String columnName,
String comment,
SqlType sqlType,
int size,
int scale,
boolean nullable,
Object defaultValue)
Determines the best migration strategy.
|
String |
getName()
Gets the name of the backend.
|
boolean |
isDefaultEqual(ColumnMetaData column,
SqlType sqlType,
Object defaultValue)
Checks whether the column's default corresponds to the model's default value.
|
boolean |
isMatchingUrl(String url)
Checks whether the backend belongs to the given jdbc url.
|
SqlType[] |
jdbcTypeToSqlType(int jdbcType,
int size,
int scale)
Converts the JDBC data type integer to a tentackle backend SqlTypes.
|
int |
setLeadingSelectParameters(BackendPreparedStatement stmt,
int limit,
int offset)
Sets optional parameters before applying the original parameters.
|
int |
setTrailingSelectParameters(BackendPreparedStatement stmt,
int index,
int limit,
int offset)
Sets optional parameters after applying the original parameters.
|
String |
sqlAddColumn(String tableName,
String columnName,
String comment,
SqlType sqlType,
int size,
int scale,
boolean nullable,
Object defaultValue)
Generates sql code to add a column.
|
String |
sqlAlterColumnComment(String tableName,
String columnName,
String comment)
Generates SQL code to alter the comment for an attribute.
|
String |
sqlAlterColumnType(String tableName,
String columnName,
String comment,
SqlType sqlType,
int size,
int scale,
boolean nullable,
Object defaultValue)
Generates sql code to change the datatype of a column.
|
String |
sqlCreateColumn(String columnName,
String comment,
SqlType sqlType,
int size,
int scale,
boolean nullable,
Object defaultValue,
boolean primaryKey,
boolean withTrailingComma)
Generates the attribute definition of a CREATE TABLE statement.
|
String |
sqlCreateTableClosing(String tableName,
String comment)
Generates the last line of a CREATE TABLE statement.
|
String |
sqlDropIndex(String schemaName,
String tableNameWithoutSchema,
String indexName)
Generates the DROP INDEX statement.
|
String |
sqlRenameAndAlterColumnType(String tableName,
String oldColumnName,
String newColumnName,
String comment,
SqlType sqlType,
int size,
int scale,
boolean nullable,
Object defaultValue)
Generates sql code to rename a column.
|
String |
sqlRenameColumn(String tableName,
String oldColumnName,
String newColumnName)
Generates sql code to rename a column.
|
String |
sqlTypeToString(SqlType sqlType,
int size)
Converts the java SQL-type to the database type name.
|
getCoalesceKeyword, getReservedWords, sqlCreateForeignKey, sqlDropForeignKey, sqlNextFromSequene, supportsSequencesassertValidName, columnTypeNullDefaultToString, columnTypeToString, createConnection, createIndexColumnMetaData, createIndexMetaData, createTableMetaData, getDefaultSize, getEmptyString, getMaxScale, getModelMetaData, getTableMetaData, isCommunicationLinkException, isConstraintException, isMatchingName, needAliasForSubselect, needSetLongWorkaround, needTxForFetchsize, optimizeSql, sqlAlterColumnDefault, sqlAlterColumnNullConstraint, sqlAlterTableComment, sqlAsBeforeTableAlias, sqlComment, sqlCreateColumnComment, sqlCreateIndex, sqlCreateTableAttributeWithoutComment, sqlCreateTableComment, sqlCreateTableIntro, sqlCreateTableIntroWithoutComment, sqlDropColumn, sqlFunction, sqlJoin, sqlJoinSelects, sqlRequiresExtraCommit, sqlResultSetIsClosedSupported, sqlUpdateToNotNull, toQuotedString, toString, valueToLiteralpublic static final String SQL_LIMIT
public static final String SQL_OFFSET
public static final String SQL_LIMIT_PAR
public static final String SQL_OFFSET_PAR
public boolean isMatchingUrl(String url)
Backendurl - the jdbc urlpublic String getName()
Backendpublic String getDriverClassName()
Backendpublic String getBackendId(Connection connection)
Backend
Useful to figure out the corresponding ManagedConnection from the backend's logfiles.
connection - the jdbc connectionpublic boolean allowsExpressionsReferringToTablesBeingUpdated()
BackendallowsExpressionsReferringToTablesBeingUpdated in interface BackendallowsExpressionsReferringToTablesBeingUpdated in class AbstractBackendpublic void buildSelectSql(StringBuilder sqlBuilder, boolean writeLock, int limit, int offset)
Backend
sqlBuilder is anything as FROM... WHERE... ORDER BY....
It is decorated with a leading SELECT plus optional clauses
like for the given parameters.
buildSelectSql in interface BackendbuildSelectSql in class AbstractSql92BackendsqlBuilder - the sql builder, initially containing the inner sql without leading SELECT.writeLock - true select should write locklimit - the limit value, ≤ 0 if no limit clauseoffset - the offset value, ≤ 0 if no offset clausepublic int setLeadingSelectParameters(BackendPreparedStatement stmt, int limit, int offset)
BackendsetLeadingSelectParameters in interface BackendsetLeadingSelectParameters in class AbstractSql92Backendstmt - the prepared statementlimit - the limit value, ≤ 0 if no limit clauseoffset - the offset value, ≤ 0 if no offset clausepublic int setTrailingSelectParameters(BackendPreparedStatement stmt, int index, int limit, int offset)
BackendsetTrailingSelectParameters in interface BackendsetTrailingSelectParameters in class AbstractSql92Backendstmt - the prepared statementindex - the first parameter indexlimit - the limit value, ≤ 0 if no limit clauseoffset - the offset value, ≤ 0 if no offset clausepublic int getMaxSize(SqlType sqlType)
BackendgetMaxSize in interface BackendgetMaxSize in class AbstractBackendsqlType - the SQL-typepublic String sqlTypeToString(SqlType sqlType, int size)
BackendsqlTypeToString in interface BackendsqlTypeToString in class AbstractBackendsqlType - the java sql typesize - the column's sizepublic SqlType[] jdbcTypeToSqlType(int jdbcType, int size, int scale)
BackendThere may be more than one sqltype returned!
jdbcTypeToSqlType in interface BackendjdbcTypeToSqlType in class AbstractBackendjdbcType - the jdbc data typesize - the column sizescale - the column's scaleTypespublic String sqlCreateTableClosing(String tableName, String comment)
BackendsqlCreateTableClosing in interface BackendsqlCreateTableClosing in class AbstractBackendtableName - the tablename with optional schema separated by a dotcomment - optional comment, null if nonepublic DatabaseMetaData[] getMetaData(BackendInfo backendInfo) throws SQLException
BackendImportant: the connection of the metadata is open!
getMetaData in interface BackendgetMetaData in class AbstractBackendbackendInfo - the backend infoSQLException - if failedpublic ColumnMetaData createColumnMetaData(TableMetaData tableMetaData)
BackendcreateColumnMetaData in interface BackendcreateColumnMetaData in class AbstractBackendtableMetaData - the table meta data this column belongs topublic boolean isDefaultEqual(ColumnMetaData column, SqlType sqlType, Object defaultValue)
BackendisDefaultEqual in interface BackendisDefaultEqual in class AbstractBackendcolumn - the column to inspectsqlType - the sql typedefaultValue - the model's default valuepublic String sqlCreateColumn(String columnName, String comment, SqlType sqlType, int size, int scale, boolean nullable, Object defaultValue, boolean primaryKey, boolean withTrailingComma)
BackendsqlCreateColumn in interface BackendsqlCreateColumn in class AbstractBackendcolumnName - the database column namecomment - optional comment, null if nonesqlType - the JDBC sql typesize - the optional sizescale - the optional scalenullable - true if NULL, else NOT NULLdefaultValue - the optional default valueprimaryKey - true if this is a primary keywithTrailingComma - true if append a commapublic String sqlAddColumn(String tableName, String columnName, String comment, SqlType sqlType, int size, int scale, boolean nullable, Object defaultValue)
BackendsqlAddColumn in interface BackendsqlAddColumn in class AbstractBackendtableName - the tablenamecolumnName - the new column namecomment - optional comment, null if nonesqlType - the JDBC sql typesize - the optional sizescale - the optional scalenullable - true if NULL, else NOT NULLdefaultValue - the optional default valuepublic String sqlRenameColumn(String tableName, String oldColumnName, String newColumnName)
BackendsqlRenameColumn in interface BackendsqlRenameColumn in class AbstractBackendtableName - the tablenameoldColumnName - the old column namenewColumnName - the new column namepublic String sqlRenameAndAlterColumnType(String tableName, String oldColumnName, String newColumnName, String comment, SqlType sqlType, int size, int scale, boolean nullable, Object defaultValue)
BackendsqlRenameAndAlterColumnType in interface BackendsqlRenameAndAlterColumnType in class AbstractBackendtableName - the tablenameoldColumnName - the old column namenewColumnName - the new column namecomment - optional comment, null if nonesqlType - the JDBC sql typesize - the optional sizescale - the optional scalenullable - true if NULL, else NOT NULLdefaultValue - the optional default valuepublic String sqlAlterColumnType(String tableName, String columnName, String comment, SqlType sqlType, int size, int scale, boolean nullable, Object defaultValue)
BackendsqlAlterColumnType in interface BackendsqlAlterColumnType in class AbstractBackendtableName - the tablenamecolumnName - the new column namecomment - optional comment, null if nonesqlType - the JDBC sql typesize - the optional sizescale - the optional scalenullable - true if NULL, else NOT NULLdefaultValue - the optional default valuepublic String sqlAlterColumnComment(String tableName, String columnName, String comment)
BackendsqlAlterColumnComment in interface BackendsqlAlterColumnComment in class AbstractBackendtableName - the table namecolumnName - the column namecomment - optional comment, null to clearBackend.sqlRenameAndAlterColumnType(java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.tentackle.sql.SqlType, int, int, boolean, java.lang.Object) insteadpublic String sqlDropIndex(String schemaName, String tableNameWithoutSchema, String indexName)
BackendsqlDropIndex in interface BackendsqlDropIndex in class AbstractBackendschemaName - the optional schema, null if nonetableNameWithoutSchema - the table name without the schemaindexName - the name of the indexpublic MigrationStrategy[] getMigrationStrategy(ColumnMetaData column, String columnName, String comment, SqlType sqlType, int size, int scale, boolean nullable, Object defaultValue)
BackendgetMigrationStrategy in interface BackendgetMigrationStrategy in class AbstractBackendcolumn - old column meta datacolumnName - new column namecomment - new commentsqlType - new sql typesize - new sizescale - new scalenullable - new nullabledefaultValue - new defaultprotected String extractWhereClause(String sql, int whereOffset)
AbstractBackendextractWhereClause in class AbstractBackendsql - the sql statementwhereOffset - the location of WHERE in sqlCopyright © 2016 Krake Softwaretechnik. All rights reserved.