public class

ImprovedNamingStrategy

extends Object
implements Serializable NamingStrategy
java.lang.Object
   ↳ org.hibernate.cfg.ImprovedNamingStrategy

Class Overview

An improved naming strategy that prefers embedded underscores to mixed case names

Summary

Fields
public static final NamingStrategy INSTANCE A convenient singleton instance
Public Constructors
ImprovedNamingStrategy()
Public Methods
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)
Return a collection table name ie an association having a join table
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
Protected Methods
static String addUnderscores(String name)
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.hibernate.cfg.NamingStrategy

Fields

public static final NamingStrategy INSTANCE

A convenient singleton instance

Public Constructors

public ImprovedNamingStrategy ()

Public Methods

public String classToTableName (String className)

Return the unqualified class name, mixed case converted to underscores

Parameters
className the fully-qualified class name
Returns
  • a table name

public String collectionTableName (String ownerEntity, String ownerEntityTable, String associatedEntity, String associatedEntityTable, String propertyName)

Return a collection table name ie an association having a join table

Parameters
ownerEntityTable owner side table name
associatedEntityTable reverse side table name if any
propertyName collection role

public String columnName (String columnName)

Convert mixed case to underscores

Parameters
columnName a column name
Returns
  • a column name

public String foreignKeyColumnName (String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName)

Return the property name or propertyTableName

Parameters
propertyName the property name involved
propertyTableName the property table name involved (logical one)
referencedColumnName the referenced column name involved (logical one)

public String joinKeyColumnName (String joinedColumn, String joinedTable)

Return the argument

Parameters
joinedColumn joined column name (logical one) used to join with
joinedTable joined table name (ie the referenced table) used to join with

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

Parameters
columnName given column name in the metadata if any
propertyName property name
referencedColumn referenced column name (logical one) in the join

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

Parameters
tableName the metadata explicit name
ownerEntityTable owner table entity table name (logical one)
associatedEntityTable reverse side table name if any (logical one)
propertyName collection role

public String logicalColumnName (String columnName, String propertyName)

Return the column name or the unqualified property name

Parameters
columnName given column name if any
propertyName property name of this column

public String propertyToColumnName (String propertyName)

Return the full property path with underscore seperators, mixed case converted to underscores

Parameters
propertyName a property path
Returns
  • a column name

public String tableName (String tableName)

Convert mixed case to underscores

Parameters
tableName a table name
Returns
  • a table name

Protected Methods

protected static String addUnderscores (String name)