FileDocCategorySizeDatePackage
DefaultNamingStrategy.javaAPI DocHibernate 3.2.53376Thu May 04 10:10:22 BST 2006org.hibernate.cfg

DefaultNamingStrategy

public class DefaultNamingStrategy extends Object implements NamingStrategy, Serializable
The default NamingStrategy
see
ImprovedNamingStrategy a better alternative
author
Gavin King

Fields Summary
public static final NamingStrategy
INSTANCE
The singleton instance
Constructors Summary
Methods Summary
public java.lang.StringclassToTableName(java.lang.String className)
Return the unqualified class name


	     	 
	    
		return StringHelper.unqualify(className);
	
public java.lang.StringcollectionTableName(java.lang.String ownerEntity, java.lang.String ownerEntityTable, java.lang.String associatedEntity, java.lang.String associatedEntityTable, java.lang.String propertyName)
Return the unqualified property name, not the best strategy but a backward compatible one

		//use a degenerated strategy for backward compatibility
		return StringHelper.unqualify(propertyName);
	
public java.lang.StringcolumnName(java.lang.String columnName)
Return the argument

		return columnName;
	
public java.lang.StringforeignKeyColumnName(java.lang.String propertyName, java.lang.String propertyEntityName, java.lang.String propertyTableName, java.lang.String referencedColumnName)
Return the property name or propertyTableName

		String header = propertyName != null ? StringHelper.unqualify( propertyName ) : propertyTableName;
		if (header == null) throw new AssertionFailure("NammingStrategy not properly filled");
		return columnName( header ); //+ "_" + referencedColumnName not used for backward compatibility
	
public java.lang.StringjoinKeyColumnName(java.lang.String joinedColumn, java.lang.String joinedTable)
Return the argument

		return columnName( joinedColumn );
	
public java.lang.StringlogicalCollectionColumnName(java.lang.String columnName, java.lang.String propertyName, java.lang.String referencedColumn)
Return the column name if explicit or the concatenation of the property name and the referenced column

		return StringHelper.isNotEmpty( columnName ) ? columnName : propertyName + "_" + referencedColumn;
	
public java.lang.StringlogicalCollectionTableName(java.lang.String tableName, java.lang.String ownerEntityTable, java.lang.String associatedEntityTable, java.lang.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

		if ( tableName != null ) {
			return tableName;
		}
		else {
			//use of a stringbuffer to workaround a JDK bug
			return new StringBuffer(ownerEntityTable).append("_")
					.append(
						associatedEntityTable != null ?
						associatedEntityTable :
						StringHelper.unqualify( propertyName )
					).toString();
		}
	
public java.lang.StringlogicalColumnName(java.lang.String columnName, java.lang.String propertyName)
Return the column name or the unqualified property name

		return StringHelper.isNotEmpty( columnName ) ? columnName : StringHelper.unqualify( propertyName );
	
public java.lang.StringpropertyToColumnName(java.lang.String propertyName)
Return the unqualified property name

		return StringHelper.unqualify(propertyName);
	
public java.lang.StringtableName(java.lang.String tableName)
Return the argument

		return tableName;