- All Known Implementing Classes:
AbstractNamingConvention
,MatchingNamingConvention
,UnderscoreNamingConvention
The main goal of the naming convention is to reduce the amount of configuration required in the mapping (especially when mapping between column and property names).
Note that if you do not define a NamingConvention the default one will be used and you can configure it's behaviour via properties.
-
Method Summary
Modifier and TypeMethodDescriptionderiveM2MColumn
(String tableName, String dbColumn) Derive a DB Column from a FK table and column.getColumnFromProperty
(Class<?> beanClass, String propertyName) Return the column name given the property name.getForeignKey
(String prefix, String fkProperty) Return the foreign key column given the local and foreign properties.getM2MJoinTableName
(TableName lhsTable, TableName rhsTable) Returns the ManyToMany join table name (aka the intersection table).getSequenceName
(String tableName, 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 Class.getTableName
(String catalog, String schema, String name) Return the full table name taking into account quoted identifiers.boolean
Return true if a prefix should be used building a foreign key name.void
loadFromProperties
(PropertiesWrapper properties) Load setting from properties.void
setDatabasePlatform
(DatabasePlatform databasePlatform) Set the associated DatabasePlaform.
-
Method Details
-
setDatabasePlatform
Set 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.
- Parameters:
databasePlatform
- the database platform
-
getTableName
Returns the table name for a given Class.This method is always called and should take into account @Table annotations etc. This means you can choose to override the settings defined by @Table if you wish.
- Parameters:
beanClass
- the bean class- Returns:
- the table name for the entity class
-
getM2MJoinTableName
Returns the ManyToMany join table name (aka the intersection table).- Parameters:
lhsTable
- the left hand side bean tablerhsTable
- the right hand side bean table- Returns:
- the many to many join table name
-
deriveM2MColumn
Derive a DB Column from a FK table and column. -
getTableName
Return the full table name taking into account quoted identifiers. -
getColumnFromProperty
Return the column name given the property name.- Returns:
- the column name for a given property
-
getSequenceName
Return 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.
- Parameters:
tableName
- the table name- Returns:
- the sequence name
-
isUseForeignKeyPrefix
boolean 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.
-
getForeignKey
Return the foreign key column given the local and foreign properties.- Parameters:
prefix
- the local column used to prefix the fk columnfkProperty
- the property name of the foreign key- Returns:
- the foreign key column
-
loadFromProperties
Load setting from properties.
-