Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Using the CFC Generator extension for ColdFusion ORM

From: ColdFusion Builder Essential Training

Video: Using the CFC Generator extension for ColdFusion ORM

ColdFusion 9's ORM features make it less necessary to spend your days building simple value objects and crud methods, but you still have to spend time typing out repetitive code and dealing with object relationships. Luckily, ColdFusion Builder helps with this as well by providing a feature rich way to build ORM CFCs without writing a line of code. So, we are going to return to our ARTISTS and ART tables and build some ORM CFCs. First off, I am going to delete the ARTISTS files we generated in our last video, so we can start over with the ORM way of doing things.

Using the CFC Generator extension for ColdFusion ORM

ColdFusion 9's ORM features make it less necessary to spend your days building simple value objects and crud methods, but you still have to spend time typing out repetitive code and dealing with object relationships. Luckily, ColdFusion Builder helps with this as well by providing a feature rich way to build ORM CFCs without writing a line of code. So, we are going to return to our ARTISTS and ART tables and build some ORM CFCs. First off, I am going to delete the ARTISTS files we generated in our last video, so we can start over with the ORM way of doing things.

In my RDS Data view, I am going to select both the ART and the ARTISTS tables. Then I will right-click, choose Adobe CFC Generator > Create ORM CFC. Now, the first dialog is pretty simple. We are just going to choose where we want the CFCs to be generated. We will stick these in our Chapter 7 folder and click OK. Then the next screen may take a bit to come up, because it's using all sorts of Flash forms in ColdFusion 9. So, as we can see, here on the left we have our two tables that I selected, and on the right-hand side, we have all of the columns for the ART tables.

If I select ARTISTS, we will see all of the columns for the ARTISTS table. I can check these boxes to determine which columns I want to actually be in my CFC. So, what we are going to do is build relationships in between the ART and the ARTISTS table. So, I will click on the ART table, and here in the Relationships section, I will click insert. Now I am going to relate the ART table to ARTISTS. I will give it a name and specify my target table, which is ARTISTS, and choose the Multiplicity.

What this means is I am going to choose whether or not there is one piece of art to one artist, one piece of art to multiple artists, multiple pieces of art to a single artist, or whether multiple artists can work on the same piece of artwork. So, I am going to choose multiple pieces of art to one artist, the n-1 relationship. Now, I don't need to choose a Link table, because this is a one-to-one relationship in between the two tables. It's not a many-to-many relationship where I need a intermediary link table. Once I have this relationship defined, I will click Save, select it again, and then I can choose the join conditions.

I need to choose the columns that relate these two tables together. I will scroll down a bit and click insert. Then I need to choose my source field, which in this case, in the ART table is the ARTISTID, and then the target field. In the ARTISTS table, that's also ARTISTID, and click Save. Now I will do the same thing for ARTISTS. I will click insert, choose my relationship name, which will be ART. Choose my target table, also ART. And the Multiplicity. One artist can have multiple pieces of artworks, so it's a 1-n relationship.

Click Save, select the relationship, and we will insert a join condition. My source field is going to be ARTISTID. My target field is also going to be ARTISTID. Click Save. If I scroll down to the bottom, we can click Generate Code. So, it says the code has successfully been generated. I will click Close. Go back to my Chapter 7 folder and refresh. Here, I can see its created an ART, ARTISTS, ARTISTSService, and ARTService.

If I open these up, you will notice in the ART.cfc, at the bottom here it has my ARTISTS property. That shows a many-to-one relationship with the ARTISTS.cfc and specifies my foreign key columns. In my ARTISTSService, I also have methods for creating new artists, deleting artists, getting all artists, a paging method, basically everything we had in the standard CFCs, but using all of the ColdFusion 9 ORM functionality to make it work. So, just like the generated code from the previous video, you can edit the handler that outputs the ORM CFCs' code to suit your needs.

As with this or any extension that generates code, always remember that if you are not happy with the output of the extension, it's worth the time to dig through the handler's directory and get everything customized to suit your specific needs.

Show transcript

This video is part of

Image for ColdFusion Builder Essential Training
ColdFusion Builder Essential Training

40 video lessons · 3879 viewers

Daniel Short
Author

 
Expand all | Collapse all
  1. 7m 48s
    1. Welcome
      59s
    2. Installing ColdFusion Builder
      2m 20s
    3. Installing ColdFusion Builder as a plug-in
      3m 18s
    4. Using the exercise files
      1m 11s
  2. 17m 42s
    1. Workspace overview
      2m 25s
    2. Organizing your workspace
      6m 19s
    3. Adding and selecting workspaces
      2m 53s
    4. Installing and managing plug-ins
      6m 5s
  3. 12m 12s
    1. Creating projects
      2m 11s
    2. Importing projects
      2m 48s
    3. Creating project working sets
      2m 23s
    4. Managing projects
      2m 22s
    5. Linking folders
      2m 28s
  4. 23m 2s
    1. Configuring and managing ColdFusion servers
      6m 26s
    2. Using the Services Browser
      4m 15s
    3. Using RDS Dataview and Fileview
      4m 52s
    4. Using FTP
      7m 29s
  5. 18m 10s
    1. Creating editor profiles
      2m 6s
    2. Using Code Assist
      5m 43s
    3. Setting code coloring
      4m 5s
    4. Using shortcut keys
      3m 5s
    5. Working with outlines and syntax checking
      3m 11s
  6. 37m 40s
    1. Using code completion
      7m 25s
    2. Using snippets
      9m 23s
    3. Using SQL editing and the Query Viewer
      5m 55s
    4. Working with components
      7m 27s
    5. Working with variable mapping
      2m 14s
    6. Navigating code and documents
      5m 16s
  7. 13m 12s
    1. Getting set up
      3m 50s
    2. Using the ColdFusion debugger
      5m 37s
    3. Watching logs with Tailview
      3m 45s
  8. 13m 8s
    1. Installing extensions
      4m 5s
    2. Using the CFC Generator extension for ColdFusion 8
      4m 52s
    3. Using the CFC Generator extension for ColdFusion ORM
      4m 11s
  9. 34m 5s
    1. Building a simple contact form extension
      3m 42s
    2. Creating user interfaces
      8m 55s
    3. Packaging the extension
      3m 55s
    4. Building the handler
      8m 10s
    5. Using the Builder extension
      9m 23s
  10. 25s
    1. Goodbye
      25s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed ColdFusion Builder Essential Training.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.