Class AbstractNamingConvention
- All Implemented Interfaces:
NamingConvention
- Direct Known Subclasses:
MatchingNamingConvention,UnderscoreNamingConvention
- Author:
- emcgreal
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstruct with the default sequence format ("{table}_seq") and useForeignKeyPrefix as true.AbstractNamingConvention(String sequenceFormat) Construct with a sequence format.AbstractNamingConvention(String sequenceFormat, boolean useForeignKeyPrefix) Construct with a sequence format and useForeignKeyPrefix setting. -
Method Summary
Modifier and TypeMethodDescriptionderiveM2MColumn(String tableName, String dbColumn) Derive a DB Column from a FK table and column.Return the catalog.getM2MJoinTableName(TableName lhsTable, TableName rhsTable) Returns the ManyToMany join table name (aka the intersection table).Return the schema.Returns the sequence format.getSequenceName(String rawTableName, String pkColumn) Return the sequence name given the table name (for DB's that use sequences).getTableName(Class<?> beanClass) Returns the table name for a given entity bean.getTableName(String catalog, String schema, String name) Return the full table name taking into account quoted identifiers.booleanReturn true if a prefix should be used building a foreign key name.voidloadFromProperties(PropertiesWrapper properties) Load settings from properties.voidsetCatalog(String catalog) Sets the catalog.voidsetDatabasePlatform(DatabasePlatform databasePlatform) Set the associated DatabasePlaform.voidSets the schema.voidsetSequenceFormat(String sequenceFormat) Set the sequence format used to generate the sequence name.voidsetUseForeignKeyPrefix(boolean useForeignKeyPrefix) Set this to false when the primary key columns matching your foreign key columns.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.ebean.config.NamingConvention
getColumnFromProperty, getForeignKey
-
Field Details
-
DEFAULT_SEQ_FORMAT
The Constant DEFAULT_SEQ_FORMAT.- See Also:
-
-
Constructor Details
-
AbstractNamingConvention
Construct with a sequence format and useForeignKeyPrefix setting. -
AbstractNamingConvention
Construct with a sequence format.- Parameters:
sequenceFormat- the sequence format
-
AbstractNamingConvention
public AbstractNamingConvention()Construct with the default sequence format ("{table}_seq") and useForeignKeyPrefix as true.
-
-
Method Details
-
setDatabasePlatform
Description copied from interface:NamingConventionSet the associated DatabasePlaform.This is set after the DatabasePlatform has been associated.
The purpose of this is to enable NamingConvention to be able to support database platform specific configuration.
- Specified by:
setDatabasePlatformin interfaceNamingConvention- Parameters:
databasePlatform- the database platform
-
getSequenceName
Description copied from interface:NamingConventionReturn the sequence name given the table name (for DB's that use sequences).Typically you might append "_seq" to the table name as an example.
- Specified by:
getSequenceNamein interfaceNamingConvention- Parameters:
rawTableName- the table name- Returns:
- the sequence name
-
getCatalog
Return the catalog. -
setCatalog
Sets the catalog. -
getSchema
Return the schema. -
setSchema
Sets the schema. -
getSequenceFormat
Returns the sequence format. -
setSequenceFormat
Set the sequence format used to generate the sequence name.The format should include "{table}". When generating the sequence name {table} is replaced with the actual table name.
- Parameters:
sequenceFormat- string containing "{table}" which is replaced with the actual table name to generate the sequence name.
-
isUseForeignKeyPrefix
Return true if a prefix should be used building a foreign key name.This by default is true and this works well when the primary key column names are simply "ID". In this case a prefix (such as "ORDER" and "CUSTOMER" etc) is added to the foreign key column producing "ORDER_ID" and "CUSTOMER_ID".
This should return false when your primary key columns are the same as the foreign key columns. For example, when the primary key columns are "ORDER_ID", "CUST_ID" etc ... and they are the same as the foreign key column names.
- Specified by:
isUseForeignKeyPrefixin interfaceNamingConvention
-
setUseForeignKeyPrefix
Set this to false when the primary key columns matching your foreign key columns. -
getTableName
Returns the table name for a given entity bean.This first checks for the @Table annotation and if not present uses the naming convention to define the table name.
- Specified by:
getTableNamein interfaceNamingConvention- Parameters:
beanClass- the bean class- Returns:
- the table name for the entity class
- See Also:
-
getTableNameFromAnnotation(Class)getTableNameByConvention(Class)
-
getM2MJoinTableName
Description copied from interface:NamingConventionReturns the ManyToMany join table name (aka the intersection table).- Specified by:
getM2MJoinTableNamein interfaceNamingConvention- Parameters:
lhsTable- the left hand side bean tablerhsTable- the right hand side bean table- Returns:
- the many to many join table name
-
deriveM2MColumn
Description copied from interface:NamingConventionDerive a DB Column from a FK table and column.- Specified by:
deriveM2MColumnin interfaceNamingConvention
-
getTableName
Description copied from interface:NamingConventionReturn the full table name taking into account quoted identifiers.- Specified by:
getTableNamein interfaceNamingConvention
-
loadFromProperties
Load settings from properties.- Specified by:
loadFromPropertiesin interfaceNamingConvention
-