Adobe CFC Generator

The Adobe CFC Generator generator generates ORM CFCs (ColdFusion Components) from database tables. The Adobe CFC Generator extension lets you create a traditional CFC or an ORM CFC from a set of tables.

Object Relational Mapping (ORM) is a programming technique that lets you define a mapping strategy to store and retrieve data from a relational database using object models. The Adobe CFC Generator lets you define the mapping for relations, specify join conditions, and generate services for the CFCs. For more information about ORM, see ColdFusion ORM in the ColdFusion Developer Guide.

Install Adobe CFC Generator

The Adobe CFC Generator extension is installed with ColdFusion Builder, if you selected the Install Extension option when creating a server.

If you did not install the extension when creating a server and want to install it now, see Install and uninstall extensions. The Adobe CFC Generator extension archive file (AdobeCfcGenerator.zip) comes packaged with ColdFusion Builder. The archive file is in the Extensions directory within the ColdFusion Builder installation.

Use Adobe CFC Generator

  1. In the ColdFusion Builder perspective, select RDS Dataview.

  2. If you have configured an RDS user name and password, specify the RDS user name and password.

    Note: You set the RDS password in the ColdFusion Administrator. Do not confuse the RDS password with the ColdFusion Administrator password, which is also managed through the ColdFusion Administrator.
  3. The list of data sources available in the configured server are listed.

  4. Select a data source and the table for which you want to generate CFCs. You can select multiple tables at once by pressing Shift and selecting the table names.

  5. Right-click the selected tables, select Adobe CFC Generator, and select one of the following options:
    Note: The Adobe CFC Generator option appears only if you right-click a table name. Clicking the data source or records within the data source does not show these options.
    Create CFC
    Generates a ColdFusion component.

    Create ORM CFC
    Generates an ORM CFC and maps it to the database.

Create CFC

  1. Right-click a table in the selected data source, for example, APP.EMPLOYEES table, and select Adobe CFC Generator > Create CFC.

  2. In the Adobe CFC Generator dialog box, do the following:

    • Specify the location to store the generated CFC.

    • Select Generate Service to automatically generate methods.

You can modify the CFC source code to provide additional functionality.

Create ORM CFC

  1. Right-click a table in the selected data source, for example, APP.EMPLOYEES table, and select Adobe CFC Generator > Create ORM CFC.

  2. Specify the location to store the generated CFCs.

  3. The Adobe CFC Generator dialog box displays the selected database tables and fields in a dynamic, editable, sortable, data grid.
    Note: Because the data grid is an Ajax-rich user interface, it can sometimes take a few moments to load.

    You can customize the ORM CFC as follows:

    • Change the CFC Name: You can edit the auto-generated CFC name in the CFC Name field.

    • Change the property name: You can edit the property name in the Property Name field.

    • Change the property type: To edit a property type, click the property type that appears in the Property Type column and select a property type from the drop-down list.

    • Specify the primary key: You can edit the primary key settings by selecting "True" or "False" for the required column.

    • You can include or exclude columns that you want to generate in the CFC by selecting or deselecting the check box next to each column name.

    • Sorting data: You can sort tables and columns that appear in the data grid. The direction of the sort can be either ascending or descending. To sort table names, click the Tables column and select the sort order. To sort column data, click the column heading and select the sort order.

  4. To generate a basic ORM CFC, click the Generate Code link.

    To define relations and join conditions for the ORM CFC, do the following:

    1. In the Relationships data grid, click Insert. A new row is inserted.

    2. Click the Relation Name field and enter a name for the relationship. For example, you can define a relationship between the Art table and Artists table.

    3. Select the target table from the Target Table drop-down list.

    4. Specify the relationship type by selecting the Multiplicity drop-down list.

    5. Specify a Link table, if necessary.

    6. Click Save.

    7. When you define a relationship, define a join condition. To define a join condition for the specified relationship, click the target table that you selected in step 3.

    8. Click Insert in the Join Conditions data grid.

    9. Select the source field from the Source drop-down list.

    10. Select the target field from the Target drop-down list.

    11. Click Save.

    12. Click the Generate Code link.

  5. In the Navigator view, right-click the folder that contains the CFC and select Refresh. You can modify the CFC source code to provide additional functionality.