ColdFusion 9 ORM Set-up
ColdFusion 9 supports ORM natively via the Hibernate framework. From the horses mouth, this is what it means:
Object relational mapping (ORM) is a programming framework that allows you to define a mapping between application object model and the relational database.
In an object model, the application objects are not aware of the database structure. Objects have properties and references to other objects. Databases consist of tables with columns that maybe related to other tables. ORM provides a bridge between the relational database and the object model. By using ORM, you can access and update data entirely using the object model of an application. ORM provides features such as:
- Database vendor independence;
- Caching;
- Concurrency;
- Performance optimization
- Developing Applications ADOBE® COLDFUSION9
Again for simplicity, I am going to use the Microsoft Adventureworks database. Assuming you have MS SQL Server installed and the Adventureworks database running, accessing data from via ColdFusion using Hibernate is pretty straight forward. Create a datasource “adventureworks” in the CF Admin pointing to your “Adventureworks” database.
Fire up Dreamweaver or ColdFusion builder and create a new site. The most important thing is to have your Application.cfc in place to enable ORM, like so:
1.) Enable ORM via Application.cfc
component
{
THIS.name = “awORM”;
THIS.ormenabled = true;
THIS.ormsettings = {datasource=’adventureworks’};
}
Like everything “ColdFusion”, the code snippet is self explanitory. I use the “script style” component as a personal preference, but a “tag style” approach is exactly the same thing.
2.) Creating your first component mapping
Create a component file called Contact.cfc with the following attributes and properties:
component table=”Contact” schema=”Person” entityname=”Contact” persistent=”true” {
property name=”ContactID” fieldtype=”id” column=”ContactID” ormtype=”integer” generator=”native”;
property name=”NameStyle” column=”NameStyle” ormtype=”string”;
property name=”Title” ormtype=”string”;
property name=”FirstName” ormtype=”string”;
property name=”MiddleName” ormtype=”string”;
property name=”LastName” ormtype=”string”;
property name=”EmailAddress” ormtype=”string”;
}
I’m using only a subset of the data, not every column in the table.
3.) Create a new page called testcontacts.cfm
Add the following lines:
<cfset myContact = entityLoad(“Contact”, 1)>
<cfdump var=”#myContact#”>
This loads the Contact from your database with the “ContactID” of 1.
*** Note: The first time you try to run the code, for whatever reason, you might get a ColdFusion error page saying the something is wrong with the “mapping”. Simply restart you ColdFusion service, and run the page again.
Looking at the “cfdump” output, expand the “METHODS” section. You will notice that ColdFusion has generated implicet “getters” and “setter” methods for you. To me this is the bargain of the month.
743 Comments to “ColdFusion 9 ORM Set-up”
Leave a Reply

Some really choice blog posts on this internet site , saved to bookmarks .
I got what you mean , saved to favorites , very nice site.
Have you ever considered publishing an ebook or guest authoring on other websites? I have a blog centered on the same subjects you discuss and would love to have you share some stories/information. I know my readers would appreciate your work. If you’re even remotely interested, feel free to send me an email.
I believe other website proprietors should take this web site as an example , very clean and great user genial pattern .
This site is my breathing in, really great design and style and perfect articles .
I besides think so , perfectly composed post! .
I really like that. You touched my heart!
Rattling great visual appeal on this website , I’d value it 10 10.
I am glad to be a visitor of this stark web site! , appreciate it for this rare info ! .
Perfect jean- Recently I purchased my first pair of True Religions. I love the first pair so much that I ordered a second pair. You have to try them… once you do, you will never put on any other pair of para.
I am glad to be a visitor of this utter web site! , regards for this rare information! .
Hey, Nice work! This is my first time i visit here. I discovered so numerous fascinating stuff in your weblog.
I’m impressed, I must say.
I conceive you have remarked some very interesting details , thanks for the post.
Greetings! This is my first comment here so I just wanted to give a quick shout out and say I genuinely enjoy reading your posts. Can you recommend any other blogs/websites/forums that go over the same topics? Thanks a lot!
I always was concerned in this topic and stock still am, regards for posting .
Deference to website author , some great entropy.
I like this post, enjoyed this one thankyou for putting up.
Real informative and great bodily structure of articles , now that’s user friendly (:.
I always was interested in this topic and stock still am, thankyou for putting up.
Very interesting topic , appreciate it for putting up.
I went over this internet site and I believe you have a lot of great info , saved to my bookmarks (:.
I believe this site holds very great written written content blog posts.
Nice post. I learn one thing on different blogs everyday. It will always be stimulating to read content from different writers and practice just a little something from their blog.
After studying a few of the weblog posts in your web site now, and I truly like your method of blogging. I bookmarked it to my bookmark web site list and will probably be checking again soon. Pls check out my site as effectively and let me know what you think.
As I website owner I believe the subject matter here is really excellent , regards for your efforts.
I really liked the article, and the very cool blog
This internet site is my breathing in, real great style and perfect content .
I like this website because so much useful stuff on here : D.
I think you are really very close on your opinion. Anyways keep it up and keep continue with your valuable thoughts. In the near upcoming future.
This is a wonderful article, I located your weblog researching bing for a related subject matter and came to this.
Would love to perpetually get updated great website ! .
There is noticeably a bundle to know about this. I assume you manufactured certain good factors in attributes also.
This web site is my inspiration , rattling great layout and perfect subject matter.
Perfect work you have done, this website is really cool with fantastic info .
hello there and thank you for your info – I have definitely picked up anything new from right here. I did however expertise several technical points using this website, as I experienced to reload the website lots of times previous to I could get it to load properly. I had been wondering if your web host is OK? Not that I am complaining, but slow loading instances times will often affect your placement in google and could damage your quality score if ads and marketing with Adwords. Well I am adding this RSS to my email and could look out for a lot more of your respective intriguing content. Ensure that you update this again soon..
I reckon something really special in this internet site .
Hi there would you mind letting me know which web host you’re using? I’ve loaded your blog in 3 different internet browsers and I must say this blog loads a lot faster then most. Can you suggest a good internet hosting provider at a fair price? Cheers, I appreciate it!
Real excellent visual appeal on this internet site , I’d rate it 10 10.
I want reading and I conceive this website got some truly useful stuff on it! .
I really like your writing style, wonderful information, thanks for posting : D.
Unquestionably believe that which you said. Your favorite reason seemed to be on the internet the simplest thing to be aware of. I say to you, I definitely get annoyed while people consider worries that they just don’t know about. You managed to hit the nail upon the top and defined out the whole thing without having side effect , people could take a signal. Will likely be back to get more. Thanks
Thank you for sharing with us, I conceive this website really stands out : D.