Top Description Fields Constructors Methods
org.hibernate.cfg

public Class ImprovedNamingStrategy

extends Object
implements NamingStrategy, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.hibernate.cfg.NamingStrategy
Imports
java.io.Serializable, org.hibernate.util.StringHelper, org.hibernate.AssertionFailure

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

Field Summary

Modifier and TypeField and Description
public static final NamingStrategy
INSTANCE

A convenient singleton instance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected static String
public String
classToTableName(String
the fully-qualified class name
className
)

Implements org.hibernate.cfg.NamingStrategy.classToTableName.

Return the unqualified class name, mixed case converted to underscores
public String
collectionTableName(String ownerEntity, String
owner side table name
ownerEntityTable
,
String associatedEntity, String
reverse side table name if any
associatedEntityTable
,
String
collection role
propertyName
)

Implements org.hibernate.cfg.NamingStrategy.collectionTableName.

Return a collection table name ie an association having a join table
public String
columnName(String
a column name
columnName
)

Implements org.hibernate.cfg.NamingStrategy.columnName.

Convert mixed case to underscores
public String
foreignKeyColumnName(String
the property name involved
propertyName
,
String propertyEntityName, String
the property table name involved (logical one)
propertyTableName
,
String
the referenced column name involved (logical one)
referencedColumnName
)

Implements org.hibernate.cfg.NamingStrategy.foreignKeyColumnName.

Return the property name or propertyTableName
public String
joinKeyColumnName(String
joined column name (logical one) used to join with
joinedColumn
,
String
joined table name (ie the referenced table) used to join with
joinedTable
)

Implements org.hibernate.cfg.NamingStrategy.joinKeyColumnName.

Return the argument
public String
logicalCollectionColumnName(String
given column name in the metadata if any
columnName
,
String
property name
propertyName
,
String
referenced column name (logical one) in the join
referencedColumn
)

Implements org.hibernate.cfg.NamingStrategy.logicalCollectionColumnName.

Return the column name if explicit or the concatenation of the property name and the referenced column
public String
logicalCollectionTableName(String
the metadata explicit name
tableName
,
String
owner table entity table name (logical one)
ownerEntityTable
,
String
reverse side table name if any (logical one)
associatedEntityTable
,
String
collection role
propertyName
)

Implements org.hibernate.cfg.NamingStrategy.logicalCollectionTableName.

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
public String
logicalColumnName(String
given column name if any
columnName
,
String
property name of this column
propertyName
)

Implements org.hibernate.cfg.NamingStrategy.logicalColumnName.

Return the column name or the unqualified property name
public String
propertyToColumnName(String
a property path
propertyName
)

Implements org.hibernate.cfg.NamingStrategy.propertyToColumnName.

Return the full property path with underscore seperators, mixed case converted to underscores
public String
tableName(String
a table name
tableName
)

Implements org.hibernate.cfg.NamingStrategy.tableName.

Convert mixed case to underscores
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INSTANCEback to summary
public static final NamingStrategy INSTANCE

A convenient singleton instance

Constructor Detail

ImprovedNamingStrategyback to summary
public ImprovedNamingStrategy()

Method Detail

addUnderscoresback to summary
protected static String addUnderscores(String name)
classToTableNameback to summary
public String classToTableName(String className)

Implements org.hibernate.cfg.NamingStrategy.classToTableName.

Return the unqualified class name, mixed case converted to underscores

Parameters
className:String

Doc from org.hibernate.cfg.NamingStrategy.classToTableName.

the fully-qualified class name

Returns:String

Doc from org.hibernate.cfg.NamingStrategy.classToTableName.

a table name

collectionTableNameback to summary
public String collectionTableName(String ownerEntity, String ownerEntityTable, String associatedEntity, String associatedEntityTable, String propertyName)

Implements org.hibernate.cfg.NamingStrategy.collectionTableName.

Doc from org.hibernate.cfg.NamingStrategy.collectionTableName.

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

Parameters
ownerEntityTable:String

owner side table name

associatedEntityTable:String

reverse side table name if any

propertyName:String

collection role

columnNameback to summary
public String columnName(String columnName)

Implements org.hibernate.cfg.NamingStrategy.columnName.

Convert mixed case to underscores

Parameters
columnName:String

Doc from org.hibernate.cfg.NamingStrategy.columnName.

a column name

Returns:String

Doc from org.hibernate.cfg.NamingStrategy.columnName.

a column name

foreignKeyColumnNameback to summary
public String foreignKeyColumnName(String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName)

Implements org.hibernate.cfg.NamingStrategy.foreignKeyColumnName.

Return the property name or propertyTableName

Parameters
propertyName:String

Doc from org.hibernate.cfg.NamingStrategy.foreignKeyColumnName.

the property name involved

propertyTableName:String

Doc from org.hibernate.cfg.NamingStrategy.foreignKeyColumnName.

the property table name involved (logical one)

referencedColumnName:String

Doc from org.hibernate.cfg.NamingStrategy.foreignKeyColumnName.

the referenced column name involved (logical one)

joinKeyColumnNameback to summary
public String joinKeyColumnName(String joinedColumn, String joinedTable)

Implements org.hibernate.cfg.NamingStrategy.joinKeyColumnName.

Return the argument

Parameters
joinedColumn:String

Doc from org.hibernate.cfg.NamingStrategy.joinKeyColumnName.

joined column name (logical one) used to join with

joinedTable:String

Doc from org.hibernate.cfg.NamingStrategy.joinKeyColumnName.

joined table name (ie the referenced table) used to join with

logicalCollectionColumnNameback to summary
public String logicalCollectionColumnName(String columnName, String propertyName, String referencedColumn)

Implements org.hibernate.cfg.NamingStrategy.logicalCollectionColumnName.

Return the column name if explicit or the concatenation of the property name and the referenced column

Parameters
columnName:String

Doc from org.hibernate.cfg.NamingStrategy.logicalCollectionColumnName.

given column name in the metadata if any

propertyName:String

Doc from org.hibernate.cfg.NamingStrategy.logicalCollectionColumnName.

property name

referencedColumn:String

Doc from org.hibernate.cfg.NamingStrategy.logicalCollectionColumnName.

referenced column name (logical one) in the join

logicalCollectionTableNameback to summary
public String logicalCollectionTableName(String tableName, String ownerEntityTable, String associatedEntityTable, String propertyName)

Implements org.hibernate.cfg.NamingStrategy.logicalCollectionTableName.

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:String

Doc from org.hibernate.cfg.NamingStrategy.logicalCollectionTableName.

the metadata explicit name

ownerEntityTable:String

Doc from org.hibernate.cfg.NamingStrategy.logicalCollectionTableName.

owner table entity table name (logical one)

associatedEntityTable:String

Doc from org.hibernate.cfg.NamingStrategy.logicalCollectionTableName.

reverse side table name if any (logical one)

propertyName:String

Doc from org.hibernate.cfg.NamingStrategy.logicalCollectionTableName.

collection role

logicalColumnNameback to summary
public String logicalColumnName(String columnName, String propertyName)

Implements org.hibernate.cfg.NamingStrategy.logicalColumnName.

Return the column name or the unqualified property name

Parameters
columnName:String

Doc from org.hibernate.cfg.NamingStrategy.logicalColumnName.

given column name if any

propertyName:String

Doc from org.hibernate.cfg.NamingStrategy.logicalColumnName.

property name of this column

propertyToColumnNameback to summary
public String propertyToColumnName(String propertyName)

Implements org.hibernate.cfg.NamingStrategy.propertyToColumnName.

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

Parameters
propertyName:String

Doc from org.hibernate.cfg.NamingStrategy.propertyToColumnName.

a property path

Returns:String

Doc from org.hibernate.cfg.NamingStrategy.propertyToColumnName.

a column name

tableNameback to summary
public String tableName(String tableName)

Implements org.hibernate.cfg.NamingStrategy.tableName.

Convert mixed case to underscores

Parameters
tableName:String

Doc from org.hibernate.cfg.NamingStrategy.tableName.

a table name

Returns:String

Doc from org.hibernate.cfg.NamingStrategy.tableName.

a table name