|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface NamingConvention
Defines the naming convention for converting between logical property names/entity names and physical DB column names/table names.
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 | |
---|---|
String |
getColumnFromProperty(Class<?> beanClass,
String propertyName)
Return the column name given the property name. |
TableName |
getM2MJoinTableName(TableName lhsTable,
TableName rhsTable)
Returns the ManyToMany join table name (aka the intersection table). |
String |
getPropertyFromColumn(Class<?> beanClass,
String dbColumnName)
Return the property name from the column name. |
String |
getSequenceName(String tableName)
Return the sequence name given the table name (for DB's that use sequences). |
TableName |
getTableName(Class<?> beanClass)
Returns the table name for a given Class. |
boolean |
isUseForeignKeyPrefix()
Return true if a prefix should be used building a foreign key name. |
void |
setDatabasePlatform(DatabasePlatform databasePlatform)
Set the associated DatabasePlaform. |
Method Detail |
---|
void setDatabasePlatform(DatabasePlatform databasePlatform)
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.
databasePlatform
- the database platformTableName getTableName(Class<?> beanClass)
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.
beanClass
- the bean class
TableName getM2MJoinTableName(TableName lhsTable, TableName rhsTable)
lhsTable
- the left hand side bean tablerhsTable
- the right hand side bean table
String getColumnFromProperty(Class<?> beanClass, String propertyName)
String getPropertyFromColumn(Class<?> beanClass, String dbColumnName)
This is used to help mapping of raw SQL queries onto bean properties.
beanClass
- the bean classdbColumnName
- the db column name
String getSequenceName(String tableName)
Typically you might append "_seq" to the table name as an example.
tableName
- the table name
boolean isUseForeignKeyPrefix()
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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |