- java.lang.Object
-
- io.ebean.config.DbConstraintNaming
-
public class DbConstraintNaming extends Object
Naming convention used for constraint names.Note that these constraint names are trimmed in the PlatformDdl which can be overridden but provides a decent default implementation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceDbConstraintNaming.MaxLengthDefines how constraint names are shortened if required based on platform limitations.
-
Field Summary
Fields Modifier and Type Field Description protected StringckPrefixprotected StringckSuffixprotected StringfkIndexMiddleprotected StringfkIndexPrefixprotected StringfkIndexSuffixprotected StringfkMiddleprotected StringfkPrefixprotected StringfkSuffixprotected StringindexMiddleprotected StringindexPrefixprotected StringindexSuffixprotected DbConstraintNaming.MaxLengthmaxLengthprotected DbConstraintNormalisenormaliseprotected StringpkPrefixprotected StringpkSuffixprotected StringuqPrefixprotected StringuqSuffix
-
Constructor Summary
Constructors Constructor 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringcheckConstraintName(String tableName, String columnName)Return the check constraint name.StringforeignKeyConstraintName(String tableName, String columnName)Return the foreign key constraint name given a single column foreign key.StringforeignKeyIndexName(String tableName, String column)Return the index name associated with a foreign key constraint given a single column foreign key.StringforeignKeyIndexName(String tableName, String[] columns)Return the index name associated with a foreign key constraint given multiple columns.DbConstraintNaming.MaxLengthgetMaxLength()Return the MaxLength implementation used to truncate/shorten db constraint names as necessary.StringindexName(String tableName, String column)Return the index name for a general index (not associated with a foreign key).StringindexName(String tableName, String[] columns)Return the index name for a general index (not associated with a foreign key).protected StringjoinColumnNames(String[] columns)Join the column names together with underscores.StringnormaliseColumn(String tableName)Normalise the column name by removing any quoted identifier characters (",',[,] etc).StringnormaliseTable(String tableName)Normalise the table name by trimming catalog and schema and removing any quoted identifier characters (",',[,] etc).StringprimaryKeyName(String tableName)Return the primary key constraint name.voidsetMaxLength(DbConstraintNaming.MaxLength maxLength)Set the MaxLength implementation used to truncate/shorten db constraint names as necessary.StringuniqueConstraintName(String tableName, String columnName)Return the unique constraint name.StringuniqueConstraintName(String tableName, String[] columns)Return the unique constraint name.
-
-
-
Field Detail
-
pkPrefix
protected String pkPrefix
-
pkSuffix
protected String pkSuffix
-
fkPrefix
protected String fkPrefix
-
fkMiddle
protected String fkMiddle
-
fkSuffix
protected String fkSuffix
-
fkIndexPrefix
protected String fkIndexPrefix
-
fkIndexMiddle
protected String fkIndexMiddle
-
fkIndexSuffix
protected String fkIndexSuffix
-
indexPrefix
protected String indexPrefix
-
indexMiddle
protected String indexMiddle
-
indexSuffix
protected String indexSuffix
-
uqPrefix
protected String uqPrefix
-
uqSuffix
protected String uqSuffix
-
ckPrefix
protected String ckPrefix
-
ckSuffix
protected String ckSuffix
-
maxLength
protected DbConstraintNaming.MaxLength maxLength
-
normalise
protected DbConstraintNormalise normalise
-
-
Constructor Detail
-
DbConstraintNaming
public DbConstraintNaming()
Construct using default of lower case for both table and column names.
-
DbConstraintNaming
public DbConstraintNaming(boolean lowerCase)
Construct specifying if lower case should be used (for both table and column names).
-
DbConstraintNaming
public DbConstraintNaming(boolean lowerCaseTableNames, boolean lowerCaseColumnNames)Construct specifying if lower case should be used for both table and column names.
-
-
Method Detail
-
getMaxLength
public DbConstraintNaming.MaxLength getMaxLength()
Return the MaxLength implementation used to truncate/shorten db constraint names as necessary.
-
setMaxLength
public void setMaxLength(DbConstraintNaming.MaxLength maxLength)
Set the MaxLength implementation used to truncate/shorten db constraint names as necessary.
-
primaryKeyName
public String primaryKeyName(String tableName)
Return the primary key constraint name.
-
foreignKeyConstraintName
public String foreignKeyConstraintName(String tableName, String columnName)
Return the foreign key constraint name given a single column foreign key.
-
foreignKeyIndexName
public String foreignKeyIndexName(String tableName, String[] columns)
Return the index name associated with a foreign key constraint given multiple columns.
-
foreignKeyIndexName
public String foreignKeyIndexName(String tableName, String column)
Return the index name associated with a foreign key constraint given a single column foreign key.
-
indexName
public String indexName(String tableName, String column)
Return the index name for a general index (not associated with a foreign key).
-
indexName
public String indexName(String tableName, String[] columns)
Return the index name for a general index (not associated with a foreign key).
-
joinColumnNames
protected String joinColumnNames(String[] columns)
Join the column names together with underscores.
-
uniqueConstraintName
public String uniqueConstraintName(String tableName, String columnName)
Return the unique constraint name.
-
uniqueConstraintName
public String uniqueConstraintName(String tableName, String[] columns)
Return the unique constraint name.
-
checkConstraintName
public String checkConstraintName(String tableName, String columnName)
Return the check constraint name.
-
normaliseTable
public String normaliseTable(String tableName)
Normalise the table name by trimming catalog and schema and removing any quoted identifier characters (",',[,] etc).
-
-