ColdFusion 9.0 Resources |
Naming strategyWhen you build a database centric application, typically you would follow some database standard and naming convention. ColdFusion ORM allows you to define this convention at one central place for the application using the 'naming strategy'. The advantage of using a naming strategy is that you do not need to change the code throughout your application. The naming strategy specifies how the table and column have to be named for a CFC and its properties. Naming strategy takes "logical name" for a table or column and returns the actual table or column name that should be used.
Naming strategy is applied to an application by setting the following in Application.cfc <cfset this.namingstrategy="strategy"> The value of strategy could be:
The cfide.orm.INamingStrategy interface is as follows: /** * Strategy to specify the table name for a CFC and column name for a property in the cfc. * This can be used to specify the application specific table and column naming convention. * This rule will be applied even if the user has specified the table/column name in the mapping so that * the name can be changed for any application at one place without changing the names in all the code. */ interface { /** * Defines the table name to be used for a specified table name. The specified table name is either * the table name specified in the mapping or chosen using the entity name. */ public string function getTableName(string tableName); /** * Defines the column name to be used for a specified column name. The specified column name is either * the column name specified in the mapping or chosen using the proeprty name. */ public string function getColumnName(string columnName); } This interface is specified in the application using: this.namingstrategy="com.adobe.UCaseStrategy" Note: The naming strategy applies to all the table or column names,
which you use in the mapping including link table and fkcolumn,
even though there is no CFC or cfproperty associated with them.
|