adobe photo shop font download

cs5 web premium cheapest adobe photoshop 7 free download adobe photoshop cs3 v10 download for windows buy cheap download adobe acrobat pdf writer free download for adobe distiller pc

adobe reader download mac osx

cheap adobe photoshop adobe after effects download adobe reader tar gz download buy cheap find free adobe download adobe 8 download

adobe download interuption

photoshop elements buy cheap download adobe reader version 5 download adobe acrobat 9 cheap internet explorer crashes upon adobe download free adobe acrobat software download

download adobe photoshop cs3 rapidshare

buy cheap adobe dreamweaver adobe acrobat 8 update download adobe photoshop cs3 iso file download cheap free adobe 8 download adobe fine reader free download

adobe flash video exporter download

adobe fireworks cheap adobe pagemaker download full free adobe acrobat 7 pro download buy cheap adobe illustrator cs 2 download for windows adobe illustrator crack download

download adobe documents

buy cheap creative suite 4 adobe master collection torrent download where to download adobe acrobat buy cheap adobe photoshop album download free download adobe illustrator cs3 mac

free adobe photoshop software download

Adobe Creative Suite 5.5 buy cheap how do i download adobe reader for free adobe version 5 download cheap download madden 2005 strategy guides to adobe reader for safe and secure free adobe flash download

unable to download adobe acrobat reader

Adobe Flash CS5.5/a> download adobe illustrator cs download adobe acrobat megaupload cheapest freeware adobe acrobat download free software download adobe reader

adobe live motion download

buy cheap Adobe After Effects CS5.5 free safe download of adobe acrobat reader download free adobe acrobat cheapest download a older version of flash player adobe free to download adobe illustrator

adobe photoshop cs 3 download

adobe software cheap download adobe acrobat reader free adobe reader slowenian download cheapest adobe acrobat 6 full download adobe acrobat 6 pro download

free trial download adobe photoshop mac

creative suite 5 cheapest download record adobe flash movie adobe patch download cheapest internet explorer crashes upon adobe download adobe flashplayer active x download

get free download of adobe flash cs3

buy online adobe incopy adobe photoshop download discount software download adobe 9 free cheap acrobat reader adobe download download the adobe photoshop cs2 book for digital photographers

adobe reader kostenloser download

adobe creative suite 5 cheap adobe 7 free download adobe premiere download cheapest adobe acrobat download vista where to download adobe acrobat

download trial version of adobe acrobat 8 professional

cheap photoshop lightroom 3 download stand alone adobe flash adobe flash palyer download cheap adobe acrobat viewer download free adobe professional download

adobe download

buy online cs5 master collection free download adobe acrobat reader professional 6 cracked adobe indesign cs2 mac download cheap adobe pdf printer download download adobe premiere pro cs3

free adobe acrobat writer download

buy online adobe premiere pro adobe cs3 patch download free adobe flshplayer 9 download buy online free adobe premiere download adobe acrobat pdf writer download

adobe illustrator and download

adobe web premium buy online download free edition adobe photoshop instructions on how to download documents on to adobe reader buy online adobe illustrator cs download adobe flash player downloader free download hunter grabber

Getting Started with ColdFusion-ORM


ColdFusion-ORM is the one of the top features in ColdFusion 9. This feature is close to my heart as I have worked on it the whole release right from its inception – specification, design, development and testing – most of the time involved in testing it. Believe it or not, I have written more than 500 test cases for ORM which include 2000+ CFM/CFC files. I am making an effort to help the community to get started on this feature by posting a series of examples that would introduce you to ColdFusion-ORM. The documentation does cover the ColdFusion-ORM stuff in good detail. But I believe in the “Learn as you code” approach. I will post a series of examples – each example would introduce a new concept in ColdFusion-ORM. I hope you would like this approach. and as you read the posts, do provide me with timely feedback so that I can mend my further examples as appropriate.

Task:
Basic ColdFusion-ORM Example

Stuff that you would learn:
To Configure ORM for a ColdFusion application.
Configuring a datasource to be used by ORM.
Mapping a table to a CFC.
Using the EntityLoad method and iterating over the resultset.
To Log the SQLs generated by ORM to the ColdFusion console.

Steps to Run the example:
- This example needs the cfartgallery. This is shipped with ColdFusion by default.
- Create a directory say “basicorm” under webroot.
- Create the following files – Application.cfc, Artists.cfc and index.cfm.
- Run the URL http://localhost:8500/basicorm/index.cfm

I have interspersed the example with a lot of comments. You can understand the concept by just following the comments starting with Application.cfc and then Artists.cfc and then index.cfm.

Application.cfc

/*
You always need a Application.cfc to work with ORM.  You
need to set ormenabled to true for the application to use ORM.
Note that ORM Configuration and mapping is generated and loaded
when the aplication starts.
*/
component
{
    //Name of the application
    this.name = "ORM_BasicExample";

    //ormenabled should be set to true so that ORM is enabled for this application
    this.ormenabled = "true";

    //Set the datasource that needs to be used by the ORM Functions.  You can also set this in the ormsettings struct
    this.datasource = "cfartgallery";

    //Set logSQL to true.  This will log SQLs to the console.
    this.ormsettings.logSQL = "true";
}

Artists.cfc

/*
FileName: Artists.cfc
Usually one CFC maps to one table. In this case, the CFC Artists.cfc maps to the table Artists. 

Persistent attribute should be set to true for cfcomponent so that ColdFusion knows
that mapping needs to generated for this CFC. 

If the name of the component is not the same as that of the table, specify the table
name. 

EntityName should be specified for the CFC which will be used by the Entity* functions
to do CRUD operations on this CFC. If EntityName is not specified, then, the name of
the component is taken as the entityname.
*/ 

component persistent="true" entityname="Artists" table="Artists"
{ 

/*Usually one property corresponds to one column in the table. In this case, the property
"firstname" corresponds to the column FIRSTNAME in the Employees table.
*/
property name="firstname"; 

/*
fieldtype="id" denotes that the property "id" is the primary key of the table Art.
ColdFusion will figure it out by inspecting the database if not specified. 

column attribute is used to define the name of the field in the table to which this
property maps to. If the column attribute is not specified, then, the name of the
property is taken as the name of the field. 

Generator attribute is used to auto-generate the primarykey when a new record is added.
Here we use increment generator. To know more about generators, refer ColdFusion ORM documentation.
*/
property name="id" column="ARTISTID" generator="increment"; 

/*
Few other properties which map to the appropriate columns in the Employees table
*/
property name="lastname";
property name="address";
property name="city";
property name="state";
property name="postalcode";
property name="email";
property name="phone";
property name="fax";
property name="thepassword"; 

} 

index.cfm

<!---
FileName: index.cfm
This is the most basic example in this kit. This example will teach you
- how to map a table to a CFC
- how to Retrieve records using the EntityLoad function.

cfartgallery datasource is used for this application.
Artists table is one of the table in cfartgallery which contains a list of
artists records.  This table is used in this example.
--->

<cfscript>
   /*
      Call ormreload() function so that ORM configuration/mapping is always created afresh
      when index.cfm is called.  This is convenirent to have in development time.  You shouldn't
      do this in production
   */
   ormreload();

    /*
     Load the Artist records to display them.  There are a number of
     variations to the EntityLoad method which will help you to retrieve
     the records the way you want. Refer the documentation for EntityLoad for details.
   */
   artists = EntityLoad("Artists");

    /*
     Display the Artist records that you just loaded
    */
    for (i=1;i<ArrayLen(artists);i++)
    {
        artistObj = artists[i];
        WriteOutput("<b>" & artistObj.getFirstName() & " " & artistObj.getLastName() & "<br></b>");
        WriteOutput("Address: " & artistObj.getAddress() & " " & artistObj.getCity() & " " &
                    artistObj.getState() & " " & artistObj.getPostalCode() & "<br>");
        WriteOutput("Ph: " & artistObj.getPhone() & "<br>");
        WriteOutput("Fax: " & artistObj.getFax() & "<br>");
        WriteOutput("EMail: " & artistObj.getEmail() & "<br>");
        WriteOutput("<br>");
    }
</cfscript>





Comments



1
Author:  Brian FitzGerald | Date:  July 14, 2009 | Time:  7:46 PM

Very helpful, thank you. I am looking forward to more. One thing in particular I’m wondering about is how easy is it to add additional methods to the object returned from hibernate… in other words, if I simply add another specialized method into Artists.cfc, will it automatically be available in every object of the result set?

Thanks!
Brian

2
Author:  Manjukiran | Date:  July 14, 2009 | Time:  8:28 PM

Hi Brian, the entities (objects) that are returned from Hibernate are indeed CFC-objects. They would contain all the methods that you add to the CFC (here Artists.cfc).

3
Author:  simon | Date:  July 21, 2009 | Time:  2:33 PM

will be nice to have an example with complex object like in adobe site, including the arts… Im looking for a cfc function with remote access to past a complexe object (from Flex) and CREATE it in one call:

ie Artist(name:simon, surname:toto, arts[painting, carving]).save

4
Author:  Leigh | Date:  July 21, 2009 | Time:  9:04 PM

Silly question, but what does “This will log SQLs to the console” mean in ColdFusion terms? Does that just mean sql statements will be written to the server logs, like a System.out.println() statement ?

-Leigh

5
Author:  Manjukiran | Date:  July 21, 2009 | Time:  10:20 PM

@simon, saving a complex object in one shot should be straight-forward. Once the object is in ColdFusion, you can save it by just calling EntitySave. Refer to this post – ColdFusion-ORM: Define One-to-Many and Many-to-one relationships for more information.

6
Author:  Manjukiran | Date:  July 21, 2009 | Time:  10:23 PM

@Leigh, if you start ColdFusion from command-line, the SQLs will be printed on the console. If you use JRun Server, then you start ColdFusion in command line using the command “jrun start coldfusion”.

7
Author:  Raghuram Reddy | Date:  November 24, 2009 | Time:  1:03 PM

Manju!!

I have a question here.
My project will not allow me to make change in application.cfc/cfm as it will impact whole appliction.
Any idea to make ORM implementation specific to the existing module.
You may say use local application.cfc.
But iam looking for ORM config related code(like this.ormenabled = “true”;) in other than application.cfc/cfm file.

Thanks,
Raghuram Reddy Gottimukkula
Adobe Certified Coldfusion Professional
Bangalroe

8
Author:  Manjukiran | Date:  November 24, 2009 | Time:  10:46 PM

Raghu, right now, there is no way you can do this. Only if orm is enabled in Application.cfc that the ORM configuration is built. Do file an enhancement – we will check if there is any work-around or support that we can provide to solve this problem.

9
Author:  Bill Brutzman | Date:  March 26, 2010 | Time:  2:37 AM

Good job Mr. Manju. I tried demo’s from a few other posts that left out some important details… leading to their apps not working.

This one works… and thus is a big help to us newbies.

10
Author:  Manjukiran | Date:  April 1, 2010 | Time:  11:31 AM

Thanks Bill. Nice to hear that it helped you.

11
Author:  AFTERSHOX » Useful resources for ramping up on CF9 ORM/Hibernate | Date:  June 8, 2011 | Time:  9:57 PM

[...] Getting Started with ColdFusion-ORM by Manju Kiran [...]



Write a Comment

Note: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>