public class DbConstraintNaming extends Object
Note that these constraint names are trimmed in the PlatformDdl which can be overridden but provides a decent default implementation.
| Modifier and Type | Class and Description |
|---|---|
static interface |
DbConstraintNaming.MaxLength
Defines how constraint names are shortened if required based on platform limitations.
|
| Modifier and Type | Field and Description |
|---|---|
protected String |
ckPrefix |
protected String |
ckSuffix |
protected String |
fkIndexMiddle |
protected String |
fkIndexPrefix |
protected String |
fkIndexSuffix |
protected String |
fkMiddle |
protected String |
fkPrefix |
protected String |
fkSuffix |
protected String |
indexMiddle |
protected String |
indexPrefix |
protected String |
indexSuffix |
protected DbConstraintNaming.MaxLength |
maxLength |
protected DbConstraintNormalise |
normalise |
protected String |
pkPrefix |
protected String |
pkSuffix |
protected String |
uqPrefix |
protected String |
uqSuffix |
| Constructor and Description |
|---|
DbConstraintNaming()
Construct using default of lower case for both table and column names.
|
DbConstraintNaming(boolean lowerCase)
Construct specifying if lower case should be used (for both table and column names).
|
DbConstraintNaming(boolean lowerCaseTableNames,
boolean lowerCaseColumnNames)
Construct specifying if lower case should be used for both table and column names.
|
| Modifier and Type | Method and Description |
|---|---|
String |
checkConstraintName(String tableName,
String columnName)
Return the check constraint name.
|
String |
foreignKeyConstraintName(String tableName,
String columnName)
Return the foreign key constraint name given a single column foreign key.
|
String |
foreignKeyIndexName(String tableName,
String column)
Return the index name associated with a foreign key constraint given a single column foreign key.
|
String |
foreignKeyIndexName(String tableName,
String[] columns)
Return the index name associated with a foreign key constraint given multiple columns.
|
DbConstraintNaming.MaxLength |
getMaxLength()
Return the MaxLength implementation used to truncate/shorten db constraint names as necessary.
|
String |
indexName(String tableName,
String column)
Return the index name for a general index (not associated with a foreign key).
|
String |
indexName(String tableName,
String[] columns)
Return the index name for a general index (not associated with a foreign key).
|
protected String |
joinColumnNames(String[] columns)
Join the column names together with underscores.
|
String |
lowerColumnName(String name)
Lower case the column name checking for quoted identifiers.
|
String |
lowerTableName(String tableName)
Lower case the table name checking for quoted identifiers.
|
String |
normaliseColumn(String tableName)
Normalise the column name by removing any quoted identifier characters (",',[,] etc).
|
String |
normaliseTable(String tableName)
Normalise the table name by trimming catalog and schema and removing any
quoted identifier characters (",',[,] etc).
|
String |
primaryKeyName(String tableName)
Return the primary key constraint name.
|
void |
setMaxLength(DbConstraintNaming.MaxLength maxLength)
Set the MaxLength implementation used to truncate/shorten db constraint names as necessary.
|
String |
uniqueConstraintName(String tableName,
String columnName)
Return the unique constraint name.
|
String |
uniqueConstraintName(String tableName,
String[] columns)
Return the unique constraint name.
|
protected String fkIndexPrefix
protected String fkIndexMiddle
protected String fkIndexSuffix
protected String indexPrefix
protected String indexMiddle
protected String indexSuffix
protected DbConstraintNaming.MaxLength maxLength
protected DbConstraintNormalise normalise
public DbConstraintNaming()
public DbConstraintNaming(boolean lowerCase)
public DbConstraintNaming(boolean lowerCaseTableNames, boolean lowerCaseColumnNames)
public DbConstraintNaming.MaxLength getMaxLength()
public void setMaxLength(DbConstraintNaming.MaxLength maxLength)
public String primaryKeyName(String tableName)
public String foreignKeyConstraintName(String tableName, String columnName)
public String foreignKeyIndexName(String tableName, String[] columns)
public String foreignKeyIndexName(String tableName, String column)
public String indexName(String tableName, String column)
public String indexName(String tableName, String[] columns)
protected String joinColumnNames(String[] columns)
public String uniqueConstraintName(String tableName, String columnName)
public String uniqueConstraintName(String tableName, String[] columns)
public String checkConstraintName(String tableName, String columnName)
public String normaliseTable(String tableName)
public String normaliseColumn(String tableName)
public String lowerTableName(String tableName)
public String lowerColumnName(String name)
Copyright © 2016. All rights reserved.