org.hibernate.cfg

Class ImprovedNamingStrategy

Implemented Interfaces:
NamingStrategy, Serializable

public class ImprovedNamingStrategy
extends java.lang.Object
implements NamingStrategy, Serializable

An improved naming strategy that prefers embedded underscores to mixed case names
Author:
Gavin King
See Also:
the default strategy

Field Summary

static NamingStrategy
INSTANCE
A convenient singleton instance

Method Summary

protected static String
addUnderscores(String name)
String
classToTableName(String className)
Return the unqualified class name, mixed case converted to underscores
String
collectionTableName(String ownerEntity, String ownerEntityTable, String associatedEntity, String associatedEntityTable, String propertyName)
String
columnName(String columnName)
Convert mixed case to underscores
String
foreignKeyColumnName(String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName)
Return the property name or propertyTableName
String
joinKeyColumnName(String joinedColumn, String joinedTable)
Return the argument
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
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
String
logicalColumnName(String columnName, String propertyName)
Return the column name or the unqualified property name
String
propertyToColumnName(String propertyName)
Return the full property path with underscore seperators, mixed case converted to underscores
String
tableName(String tableName)
Convert mixed case to underscores

Field Details

INSTANCE

public static final NamingStrategy INSTANCE
A convenient singleton instance

Method Details

addUnderscores

protected static String addUnderscores(String name)

classToTableName

public String classToTableName(String className)
Return the unqualified class name, mixed case converted to underscores
Specified by:
classToTableName in interface NamingStrategy

collectionTableName

public String collectionTableName(String ownerEntity,
                                  String ownerEntityTable,
                                  String associatedEntity,
                                  String associatedEntityTable,
                                  String propertyName)
Specified by:
collectionTableName in interface NamingStrategy

columnName

public String columnName(String columnName)
Convert mixed case to underscores
Specified by:
columnName in interface NamingStrategy

foreignKeyColumnName

public String foreignKeyColumnName(String propertyName,
                                   String propertyEntityName,
                                   String propertyTableName,
                                   String referencedColumnName)
Return the property name or propertyTableName
Specified by:
foreignKeyColumnName in interface NamingStrategy

joinKeyColumnName

public String joinKeyColumnName(String joinedColumn,
                                String joinedTable)
Return the argument
Specified by:
joinKeyColumnName in interface 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:
logicalCollectionColumnName in interface 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:
logicalCollectionTableName in interface NamingStrategy

logicalColumnName

public String logicalColumnName(String columnName,
                                String propertyName)
Return the column name or the unqualified property name
Specified by:
logicalColumnName in interface NamingStrategy

propertyToColumnName

public String propertyToColumnName(String propertyName)
Return the full property path with underscore seperators, mixed case converted to underscores
Specified by:
propertyToColumnName in interface NamingStrategy

tableName

public String tableName(String tableName)
Convert mixed case to underscores
Specified by:
tableName in interface NamingStrategy