public abstract class BasicDatabaseDialect extends Object implements DatabaseDialect
DatabaseDialect
.Modifier and Type | Field and Description |
---|---|
protected static int |
DEFAULT_MAX_CONSTRAINT_NAME_LENGTH |
protected static String |
KEY_CURRENT |
protected static String |
KEY_TARGET |
Constructor and Description |
---|
BasicDatabaseDialect() |
Modifier and Type | Method and Description |
---|---|
String |
areColumnsEqual(TableColumn target,
TableColumn current)
Determines if two given column are equal or not.
|
protected boolean |
areDefaultsDifferent(TableColumn target,
TableColumn current) |
protected boolean |
areTypesEqual(int type,
int other) |
protected String |
checkColumnSettings(TableColumn target,
TableColumn current) |
protected boolean |
checkForEquality(String left,
String right) |
Table |
completeTableInfos(Table table)
Performs DB-specific functions after a
Table was read from the
DB-metadata. |
protected int |
ensurePositiveLength(TableColumn column,
int defaultValue) |
protected boolean |
equalValue(String left,
String right) |
String |
generateAddForeignKey(Table table,
ForeignKey key)
Alters the table so that the given foreign key is added
|
String |
generateAddKey(Table table,
Key key)
Alters the table so that the given key is added
|
List<String> |
generateAlterForeignKey(Table table,
ForeignKey from,
ForeignKey to)
Alters the table so that the given foreign key is updated
* @param table the table to alter
|
List<String> |
generateAlterKey(Table table,
Key from,
Key to)
Alters the table so that the given key is updated
|
List<String> |
generateAlterPrimaryKey(Table table)
Alters the table so that the PK is updated.
|
String |
generateDropColumn(Table table,
TableColumn col)
Generates an alter statement to drop the given column.
|
String |
generateDropForeignKey(Table table,
ForeignKey key)
Alters the table so that the given foreign key is dropped
|
String |
generateDropKey(Table table,
Key key)
Alters the table so that the given key is dropped
|
String |
generateDropTable(Table table)
Builds a DROP TABLE statement.
|
protected int |
getConstraintCharacterLimit()
Determines the length a constraint should have.
|
protected String |
getDefaultValueAsString(TableColumn col) |
String |
getEffectiveKeyName(Table targetTable,
Key key)
Computes the effective name used for a key.
|
protected sirius.kernel.commons.Value |
getEngine(Table table) |
int |
getJDBCType(Class<?> clazz)
Converts the given class into the JDBC-Value (@see
Types ). |
protected String |
getTypeName(TableColumn column) |
protected boolean |
hasEscapedDefaultValue(TableColumn col) |
protected boolean |
in(int type,
int other,
int... types) |
protected boolean |
isNeedsQuotation(TableColumn col) |
protected int |
resolveType(Class<?> clazz) |
String |
translateColumnName(String name)
Converts the name (casing) to the one, used by the DB.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
generateAddColumn, generateAlterColumnTo, generateCreateTable, isColumnCaseSensitive, shouldDropKey
protected static final String KEY_TARGET
protected static final String KEY_CURRENT
protected static final int DEFAULT_MAX_CONSTRAINT_NAME_LENGTH
public int getJDBCType(Class<?> clazz)
DatabaseDialect
Types
).getJDBCType
in interface DatabaseDialect
clazz
- the type to convertpublic Table completeTableInfos(Table table)
DatabaseDialect
Table
was read from the
DB-metadata. This can be used to change column types or default values.completeTableInfos
in interface DatabaseDialect
table
- the table object to enhanceprotected boolean hasEscapedDefaultValue(TableColumn col)
public String generateAddForeignKey(Table table, ForeignKey key)
DatabaseDialect
generateAddForeignKey
in interface DatabaseDialect
table
- the table to alterkey
- the key to addpublic String generateAddKey(Table table, Key key)
DatabaseDialect
generateAddKey
in interface DatabaseDialect
table
- the table to alterkey
- the key to addpublic List<String> generateAlterForeignKey(Table table, ForeignKey from, ForeignKey to)
DatabaseDialect
generateAlterForeignKey
in interface DatabaseDialect
table
- the table to alterfrom
- the key as currently present in the databaseto
- the key as defined in the schemapublic List<String> generateAlterKey(Table table, Key from, Key to)
DatabaseDialect
generateAlterKey
in interface DatabaseDialect
table
- the table to alterfrom
- the key as currently present in the databaseto
- the key as defined in the schemapublic List<String> generateAlterPrimaryKey(Table table)
DatabaseDialect
generateAlterPrimaryKey
in interface DatabaseDialect
table
- the table to alterpublic String generateDropColumn(Table table, TableColumn col)
DatabaseDialect
generateDropColumn
in interface DatabaseDialect
table
- the table to altercol
- the column to droppublic String generateDropForeignKey(Table table, ForeignKey key)
DatabaseDialect
generateDropForeignKey
in interface DatabaseDialect
table
- the table to alterkey
- the key to droppublic String generateDropKey(Table table, Key key)
DatabaseDialect
generateDropKey
in interface DatabaseDialect
table
- the table to alterkey
- the key to droppublic String generateDropTable(Table table)
DatabaseDialect
generateDropTable
in interface DatabaseDialect
table
- the table to droppublic String translateColumnName(String name)
DatabaseDialect
translateColumnName
in interface DatabaseDialect
name
- the name of the columnprotected int resolveType(Class<?> clazz)
public String areColumnsEqual(TableColumn target, TableColumn current)
DatabaseDialect
areColumnsEqual
in interface DatabaseDialect
target
- the target column as expected by the schemacurrent
- the current database column was read from the metadataprotected boolean areDefaultsDifferent(TableColumn target, TableColumn current)
protected String checkColumnSettings(TableColumn target, TableColumn current)
protected String getDefaultValueAsString(TableColumn col)
protected boolean isNeedsQuotation(TableColumn col)
protected boolean areTypesEqual(int type, int other)
protected boolean in(int type, int other, int... types)
protected String getTypeName(TableColumn column)
protected int ensurePositiveLength(TableColumn column, int defaultValue)
public String getEffectiveKeyName(Table targetTable, Key key)
DatabaseDialect
getEffectiveKeyName
in interface DatabaseDialect
targetTable
- the table which contains the keykey
- the key itselfprotected sirius.kernel.commons.Value getEngine(Table table)
protected int getConstraintCharacterLimit()
Copyright © 2018. All rights reserved.