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

Thankyou for all your efforts that you have put in this. very interesting information.
A lot of thanks for your own efforts on this web page. Betty delights in participating in internet research and it is simple to grasp why. A number of us hear all regarding the lively medium you give priceless tips and hints via this web blog and encourage participation from some other people on this matter and my daughter is in fact starting to learn a whole lot. Enjoy the remaining portion of the year. You have been performing a really great job.
Some genuinely nice stuff on this website , I enjoy it.
Outstanding post, I conceive website owners should learn a lot from this web site its really user pleasant.
Oh my goodness! a tremendous article dude. Thanks Nonetheless I’m experiencing situation with ur rss . Don’t know why Unable to subscribe to it. Is there anyone getting equivalent rss downside? Anyone who is aware of kindly respond. Thnkx
Regards for all your efforts that you have put in this. very interesting info .
If you’re still on the fence: grab your favorite earphones, head down to a Best Buy and ask to plug them into a Zune then an iPod and see which one sounds better to you, and which interface makes you smile more. Then you’ll know which is right for you.
There are some interesting points on this article however I don’t know if I see all of them middle to heart. There may be some validity but I will take hold an opinion until I look into it further. Good article , thanks and we would like more! Added to FeedBurner as well.
After examining a number of of the weblog posts on your website now, and I actually like your method of blogging. I bookmarked it to my bookmark web site checklist and can be checking back soon. Pls check out my web page as effectively and let me know what you think.
Nice post. I learn one thing on totally different blogs everyday. It’s going to always be stimulating to read content from other writers and observe somewhat something from their blog.
I conceive this site has very good indited written content content .
Thank you for this. LOL.
I like this site its a master peace ! Glad I discovered this on google .
Can I simply say what a relief to find someone who truly knows what they’re talking about on the internet.
I am often blogging and i really appreciate your content. The article has really peaked my interest. I am going to bookmark your site and keep checking for new information.
I rattling thankful to find this web site on bing, just what I was searching for : D too saved to fav.
Thanks for spending the time to discuss this, I feel strongly about it and love reading more on this topic.
Youre so cool! I dont suppose Ive read anything like this before. So nice to find somebody with some original thoughts on this subject.
After examining a couple of of the blog posts in your web site now, and I really like your means of blogging. I bookmarked it to my bookmark website list and shall be checking back soon. Pls take a look at my web site as effectively and let me know what you think.
Glad to be one of the visitors on this awful site : D.
This actually answered the drawback, thanks!
Sweet website , super layout, very clean and utilize genial .
Nice post. I study one thing on totally different blogs everyday. It’s going to at all times be stimulating to read content from different writers and follow just a little something from their blog.
I reckon something truly interesting about your blog so I bookmarked .
Good article , thanks and we want more! Added to FeedBurner as well
I dugg some of you post as I thought they were handy handy
Aw, this was a really nice post. In thought I would like to write like this – taking time and actual effort to make a very good article is very rare…
There’s a bundle to find out about this. You made nice points also.
I’d perpetually want to be update on new articles on this website , saved to fav! .
Best Xrumer service – we post your marketing message up to 100K forums worldwide price starting only form $29
Get great online web traffic using amazing xrumer blast available. We are able post your marketing message up to 100K forums around the web, get insane amount of backlinks and great online web traffic in very short time. Most affordable and most powerful service for web traffic and backlinks in the world!!!!
Your post will be published up to 100000 forums worldwide your website will get insatnt traffic and massive increase in seo rankings just after few days or weeks. Order now:
xrumer
very clever I thought. Letterman would be proud.
After researching a couple of of the weblog posts in your web site now, and I actually like your approach of blogging. I bookmarked it to my bookmark web site list and might be checking back soon. Pls try my website as well and let me know what you think.
I’m experiencing a situation with your rss feed . Don’t know why I am not able to subscribe to it. Is there anybody getting similar rss problem? Anybody who is aware of kindly respond. Thanks
Sweet website , super layout, very clean and employ genial .
It’s best to participate in a contest for probably the greatest blogs on the web. I’ll recommend this web site!
Sweet website , super pattern , really clean and utilise genial .
Can I just say what a relief to find someone who actually knows what theyre talking about on the internet.
I like your way of blogging. I bookmarked it to my bookmark website list and will be checking back soon.
You made some first rate points there. I looked on the internet for the problem and located most individuals will go together with together with your website.
The one who wills is the one who can.
I really delighted to find this internet site on bing, just what I was looking for : D likewise saved to favorites .
Valuable information. Fortunate me I found your website unintentionally, and I’m shocked why this coincidence did not happened in advance! I bookmarked it.
Great post, I conceive people should acquire a lot from this weblog its rattling user friendly .
I am glad to be a visitor of this complete website ! , thankyou for this rare information! .
I am not very great with English but I find this rattling easy to translate.
I visited a lot of website but I conceive this one holds something special in it in it
Hi this is a fantastic article. I’m going to mail this to my associates. I stumbled on this while browsing on aol I’ll be sure to come back. thanks for sharing.
Hello would you mind letting me know which hosting company you’re utilizing? I’ve loaded your blog in 3 different web browsers and I must say this blog loads a lot quicker then most. Can you recommend a good web hosting provider at a fair price? Thanks a lot, I appreciate it!
I conceive this web site has very great composed subject matter articles .
I gotta bookmark this web site it seems invaluable invaluable