Ben Nadel
On User Experience (UX) Design, JavaScript, ColdFusion, Node.js, Life, and Love.
I am the chief technical officer at InVision App, Inc - a prototyping and collaboration platform for designers, built by designers. I also rock out in JavaScript and ColdFusion 24x7.
Meanwhile on Twitter
Loading latest tweet...
Ben Nadel at cf.Objective() 2013 (Bloomington, MN) with: Loveena Dsouza

ColdFusion ORM: A Guide To Developing Applications Using ColdFusion ORM By John Whish

By Ben Nadel on
Tags: Books, ColdFusion

Over the weekend, I finally got to read ColdFusion ORM: A Guide to Developing Applications Using ColdFusion ORM by John Whish. With the release of ColdFusion 9, Adobe has fully integrated Hibernate - the industry leader in Object Relational Mapping (ORM) - into the core language. With the release of the ColdFusion updater - 9.0.1 - a number of critical differences were made to the Hibernate implementation. ORM is some hard stuff! Not only does it require you to change much of how you think about building applications, ORM, in and of itself, is a tricky beast. Luckily, this book masterfully ties it all together in an easy to understand, tangible set of examples and explanations.


 
 
 

 
ColdFusion ORM: A Guide To Developing Applications Using ColdFusion ORM By John Whish. Review by Ben Nadel. 
 
 
 

If you've followed the Object Relational Mapping (ORM) technology emerge in the ColdFusion world, you've probably seen a number of super smart people stumble over the caveats of ColdFusion's integration with the underlying Hibernate engine. This is because ORM is complicated; everything from the session management to bidirectional relationships to lazy loading needs to be understood in order for your application to run optimally and as expected. Missing even little things like the "inverse" attribute can end up leaving you with unsaved data and possible runtime errors.

Don't let me scare you off, though; Object Relational Mapping (ORM) is a powerful tool. And, the ColdFusion ORM API does a wonderful job of simplifying the vastly complex functionality and configuration of the underlying Hibernate engine. It's just that, with this technology, the devil is in the details. In ColdFusion ORM, John Whish takes you through building a Blogging application, one ColdFusion component at a time. With each CFC, he explains how to set up persistence, configure the synthesized getters and setters, define the relationships, and optimize the generated SQL statements for performance.

Reading this book will leave you with an excellent understanding of the ORM landscape. It will not, and was not intended to, replace the ColdFusion documentation; but, it will give you a mental model of how the entire ORM world comes together. This includes how to configure every part of your application, when and how to use the features of HQL (Hibernate Query Language), and when to rely on plain old SQL statements. If you're getting into ORM, this is definitely a book you should read.


Looking For A New Job?

100% of job board revenue is donated to Kiva. Loans that change livesFind out more »

Reader Comments

Ben,

Completely off-topic (sorry) but I noticed you wearing a Mura shirt. I've toyed with Mura but haven't built a full-fledged site with it yet. I'd love to read some articles on your experiences with it if you ever find the time.

Great blog. Thanks!

Reply to this Comment

Gonna have to give this a read. I have a large project which we started intrgrating ORM into. I started learning the hard way wait CF 9.0, it'd be nice to have some independent confirmation I'm thinking the right way.

Reply to this Comment

Based on what you've read/experienced, what do you think is the most influential criteria in deciding whether or not to implement ORM in your application?

Reply to this Comment

I tried to buy the PDF version, but the stupid folks at PayPal decided not to take my US, my UK or my Belgium debit card……. FANTASTIC

I hope to be able to get my hands on the book soon

Reply to this Comment

Awesome! I've been wanting to learn this but didn't know where to start. Looking through the CF documentation, I always had questions about how things were working in the background to maintain the data, but I'll definitely give this a look based on your description!

Reply to this Comment

Glowing words of praise to be sure but let me ask a quick little follow up question. How would this read for someone who currently knows nothing about ORM? As in would this be a good book to purchase to get into it starting from nothing or is there something I should read in between?

Reply to this Comment

Thanks Ben!
I think for the price of going to a conference, one could buy every ColdFusion book that's currently in print.

Reply to this Comment

I'm working on my website at home in CF9, and am very interested in taking full advantage of ORM and Hibernate, however, he doesn't seem to offer a free chapter or even some sample pages.

Reply to this Comment

Firstly, thank you Ben for posting your review - especially as you seem to like the book!!! :)

I hope people don't mind me posting answers to their questions...

@Justin - adopting CF ORM or any new way of working is painful at first, but once you've got the hang of it then I believe it is well worth investing the time. I also think that even if you don't decide to use a new technology you can often learn a lot just by trying it out.

@Darrin - are you still having trouble?

@Joseph - The book starts by talking about how to configure it and a brief background to what it is and does. If you are familiar with ColdFusion then I don't think you'll have any problem following along. Most things are demonstrated with code samples.

@Aaron - I haven't really thought about a free chapter. If you've ever read my blog then hopefully you'll get an idea of my writing style. There is actually a generated preview on the Lulu site if you hit the "preview" link on: http://www.lulu.com/product/paperback/coldfusion-orm/18465758

Thank you all for your interest!!

- John

Reply to this Comment

@John-

I appreciate the link, however the preview just provides prefaces, special thanks and a table of contents; there's no actual content or writing style to evaluate.

I may just take the plunge. I really want a firm understanding of ORM, and after skimming through the topics in the ToC, if it can teach those things, I think I'll be able to hit the ground running.

Reply to this Comment

@Aaron - I've been playing around with the preview on the Lulu site and have managed to get it show the first chapter if you are interested. Feel free to hit me up if you have any other questions so that I don't hi-jack Ben's blog :)

Reply to this Comment

@PMascari,

I've not really tried Mura myself. But I've seen a few presentations and talked to some people who use it regularly. It looks awesome. And the people who build CMS's with it say that it's super easy to use and very powerful.

@Joe,

You never have to worry about typos with me :) I'm convinced my poor spelling is a genetic trait ;) I've got your back!

@Justin,

That's an excellent question. I, personally, still struggle to wrap my head around some of the more complex Object Oriented concepts (I have some irksome mental blocks with all this stuff). I think the hardest part for me is just learning to think in terms of objects from the very beginning and NOT from the point of view of the database.

That said, the people that I talk to that use ORM on a regular basis tell me that they would never do an app any other way going forward. So, perhaps the question is not IF you should use ORM; perhaps the question is really where in a given app ORM helps and where you should be deferring to HQL or SQL for querying purposes.

Sorry my answer is not more definite; I'm still on ColdFusion 8 for most things, so I haven't taken the full plunge into ORM just yet.

@Darrin,

Yikes, that sucks :( Sorry to hear that.

@Joseph,

Great question! I think this book would read really well. As long as you know how ColdFusion components work, this book should be good. I don't know very much about ORM at all. I think on my site, I have maybe 2 posts about ORM. I'm still mostly on CF8, so I don't have much field-experience with ORM in ColdFusion 9. But, that said, John really walks you through the app quite nicely, explaining all the details of how data gets flushed, how it gets stored, how it gets cached, and how the relationships work. I think you'd like this.

@Phillip,

Ha ha, probably :D

@Brian,

Awesome! I hope you enjoy it as much as I did.

Reply to this Comment

Ben,

Just re-installed CF9 at home and trying to learn Hibernate at work with Java.

Any updates in the past couple of months? I actually Googled "CF9 ORM Ben Nadel" hoping you'd have even more about it.

Checking out the Lulu link now.

Reply to this Comment

Ben,

I've been using CF for about 4 months and came across a problem using ORM that I haven't seen addressed anywhere else.

You seem to be one of the more knowledgeable CF developers and I've enjoyed reading and learning from your blogs.

I was hoping you could comment on the problem I'm having with ORM.

The problem is that hibernate is doing two inserts when I attempt to save a new entity. The first insert is successful, but the second errors because of duplicates.

My first question is why is it doing two inserts to start with (per the hibernate log)? The below code shows the uses of EntitySave after the EntityNew. The error occurs after the EntitySave and the message states:

Duplicate entry 'xxx' for key 'name'

Here is the code:

<cfset obj = EntityNew("#form.objname#")>
<cfset obj.setName("#form.name#")>
<cfset obj.setContact("#form.contact#")>
<cfset obj.setDescription("#form.description#")>
<cftry>
<cfset EntitySave(obj, "true")>
<cfcatch type="any" >
<cfif FindNoCase("duplicate", cfcatch.Message) GT 0>
<cfset errors["name"] = cfcatch.Message />
<cfelse>
<cfset errors["process"] = "There was an error processing 'EntitySave()' - errMsg: #cfcatch.detail#" />
</cfif>
</cfcatch>
</cftry>

Here is the log entry:

Hibernate:
insert
into
area
(activedate, isactive, inactivedate, name, description, leader)
values
(?, ?, ?, ?, ?, ?)
Hibernate:
insert
into
area
(activedate, isactive, inactivedate, name, description, leader)
values
(?, ?, ?, ?, ?, ?)
03/06 11:44:40 [web-6] HIBERNATE ERROR - Duplicate entry 'xxx' for key 'name'

03/06 11:44:40 [web-6] ERROR Duplicate entry 'xxx' for key 'name'

I bought John Whish's book on ORM and as far as I can tell I doing everything correctly.

Any advise or guidance you can provide will be greatly appreciated.

Thanks,

Scott

Reply to this Comment

@Scott, firstly welcome to CF - always nice to see a new developer :) I know you asked Ben, so I hope neither of you mind me hoping on the conversation.

It looks like you are assigning the key yourself, can you post your code for the 'area' entity? It's a bit hard to tell what is happening without seeing that.

Also, so you have event handling set up or anything in the onRequestStart / onRequestEnd that might cause odd behaviour?

BTW: you can save yourself some typing by not using the #'s when referencing variables like so:

<cfset obj = EntityNew(form.objname)>
<cfset obj.setName(form.name)>
<cfset obj.setContact(form.contact)>
<cfset obj.setDescription(form.description)>

Reply to this Comment

Post A Comment

You — Get Out Of My Dreams, Get Into My Comments
Live in the Now
Oops!
Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.