Package org.beangle.orm.hibernate
Class RailsNamingStrategy
- java.lang.Object
-
- org.beangle.orm.hibernate.RailsNamingStrategy
-
- All Implemented Interfaces:
Serializable,org.hibernate.cfg.NamingStrategy
public class RailsNamingStrategy extends Object implements org.hibernate.cfg.NamingStrategy, Serializable
类似Rails的数据库表名、列名命名策略- Author:
- chaostone
- See Also:
the default strategy, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description RailsNamingStrategy()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static StringaddUnderscores(String name)StringclassToTableName(String className)根据实体名(entityName)命名表StringcollectionTableName(String ownerEntity, String ownerEntityTable, String associatedEntity, String associatedEntityTable, String propertyName)Collection TableStringcolumnName(String columnName)对配置文件起好的列名,不进行处理StringforeignKeyColumnName(String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName)Return the property name or propertyTableNameTableNamingStrategygetTableNamingStrategy()StringjoinKeyColumnName(String joinedColumn, String joinedTable)Return the argumentStringlogicalCollectionColumnName(String columnName, String propertyName, String referencedColumn)Return the column name if explicit or the concatenation of the property name and the referenced columnStringlogicalCollectionTableName(String tableName, String ownerEntityTable, String associatedEntityTable, String propertyName)Returns either the table name if explicit or if there is an associated table, the concatenation of owner entity table and associated table otherwise the concatenation of owner entity table and the unqualified property nameStringlogicalColumnName(String columnName, String propertyName)数据列的逻辑名StringpropertyToColumnName(String propertyName)根据属性名自动起名voidsetTableNamingStrategy(TableNamingStrategy tableNamingStrategy)StringtableName(String tableName)对自动起名和使体内集合配置的表名,添加前缀protected static Stringunqualify(String qualifiedName)
-
-
-
Method Detail
-
classToTableName
public String classToTableName(String className)
根据实体名(entityName)命名表- Specified by:
classToTableNamein interfaceorg.hibernate.cfg.NamingStrategy- Parameters:
className-
-
tableName
public String tableName(String tableName)
对自动起名和使体内集合配置的表名,添加前缀配置好的实体表名和关联表的名字都会经过此方法。
- Specified by:
tableNamein interfaceorg.hibernate.cfg.NamingStrategy
-
columnName
public String columnName(String columnName)
对配置文件起好的列名,不进行处理- Specified by:
columnNamein interfaceorg.hibernate.cfg.NamingStrategy
-
logicalColumnName
public String logicalColumnName(String columnName, String propertyName)
数据列的逻辑名如果有列名,不做处理,否则按照属性自动起名. 该策略保证columnName=logicalColumnName
- Specified by:
logicalColumnNamein interfaceorg.hibernate.cfg.NamingStrategy
-
propertyToColumnName
public String propertyToColumnName(String propertyName)
根据属性名自动起名将混合大小写,带有.分割的属性描述,转换成下划线分割的名称。 属性名字包括:简单属性、集合属性、组合属性(component.name)
- Specified by:
propertyToColumnNamein interfaceorg.hibernate.cfg.NamingStrategy- Parameters:
propertyName-
-
joinKeyColumnName
public String joinKeyColumnName(String joinedColumn, String joinedTable)
Return the argument- Specified by:
joinKeyColumnNamein interfaceorg.hibernate.cfg.NamingStrategy
-
foreignKeyColumnName
public String foreignKeyColumnName(String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName)
Return the property name or propertyTableName- Specified by:
foreignKeyColumnNamein interfaceorg.hibernate.cfg.NamingStrategy
-
collectionTableName
public String collectionTableName(String ownerEntity, String ownerEntityTable, String associatedEntity, String associatedEntityTable, String propertyName)
Collection Table- Specified by:
collectionTableNamein interfaceorg.hibernate.cfg.NamingStrategy
-
logicalCollectionTableName
public String logicalCollectionTableName(String tableName, String ownerEntityTable, String associatedEntityTable, String propertyName)
Returns either the table name if explicit or if there is an associated table, the concatenation of owner entity table and associated table otherwise the concatenation of owner entity table and the unqualified property name- Specified by:
logicalCollectionTableNamein interfaceorg.hibernate.cfg.NamingStrategy
-
logicalCollectionColumnName
public String logicalCollectionColumnName(String columnName, String propertyName, String referencedColumn)
Return the column name if explicit or the concatenation of the property name and the referenced column- Specified by:
logicalCollectionColumnNamein interfaceorg.hibernate.cfg.NamingStrategy
-
setTableNamingStrategy
public void setTableNamingStrategy(TableNamingStrategy tableNamingStrategy)
-
getTableNamingStrategy
public TableNamingStrategy getTableNamingStrategy()
-
-