ORM vs. SQL in ColdFusion, which is better?
This morning I was reading through Marcos Placona's review of John Farrar's ColdFusion 9 Developer Tutorial. When talking about the chapter on ColdFuion's built in Hibernate ORM functionality, he said something that really seemed to jump out at me.
"ORM really seems magical, and will do wonders for small to medium projects, where high performance is not the major concern."
What really struck me about that comment is the suggestion that for really high performance applications you may not want to use CF's ORM. I had not considered this. I'll admit that I know very little about ORM, and have never done anything with it. I want to, but just haven't had the chance. I've got an idea for one of my personal projects that I want to start on soon, and I was planning on using ColdFusion's built in ORM for it. But, now I have to wonder, is it the right choice for my application?
This really got me to thinking, at what point does your application outgrow ORM? (or does it?) If you were building an application that's going to be large scale, high traffic, with millions of DB transactions per day, would you use ORM or avoid it favor of something else?
Since I know so little about ORM, I wanted to reach out to the community to get some opinions. Is ColdFusion's built in Hibernate ORM better suited for smaller-to-mid sized applications than larger high traffic applications, or can it handle anything you throw at it?


Looking at the Hibernate config options you have under the hood I should imagine it's possible to scale it out quite well especially with clusters of app and db servers running alongside good caching services and other must have tools for high traffic / throughput apps.
When scaling any app you've got to look at which aspects of the whole range of servers and services are slowing you down / bottlenecking and Hibernate has a lot of very clever caching and performance enhancing attributes out of the box that would take quite some effort to replicate in a home brew DAL. Yes in theory non ORM sites should be faster but that requires a good understanding of DBA and SQL optimisation (also needed for ORM) and requires a lot more work to maintain.
Like anything it comes down to how well you can design and understand the limitations of the tool set when developing the architecture for your app and that applies equally with ORM or without.
@Rob - I've heard a lot of good things about Hibernate and figured it was tweaked and had, as you said, "a lot of very clever caching and performance enhancing attributes out of the box". That's why I was so intrigued when I read Marcos' comment. I personally have always assumed the ORM performance would be on par with or better than running plain 'ole SQL queries via CF.
@Henry - good point. I can definitely see mixing ORM and Stored Procs/SQL for certain things.
The problem is the exact same problem can occur without ORM in standard queries as well.
Just like a badly written SQL Query can be bad, so can a badly written Domain Model.
I never saw hibernate implemented on a small project in my life. Point is not prerformance ( you always can pump more power ) but scalability. Orm = scale ; Sql = no scale
:)
And I am personally using CF-ORM in a small scale application right now with around 6 tables, but I expect this to scale to more tables and hopefully a larger project over time.
@Eric - a further assumption but once you reach a certain level of required throughput then it may be simpler to manage and maintain DB IO without ORM. Of course by the time you get to that point (I'm thinking Twitter-esque scale) you would have whole teams of DBAs ensuring your data layer is as performant as humanly possible. You also have other concerns for larger enterprise apps (reporting and data mining ability, OLAP etc.) which may introduce requirements that render ORM unsuitable.
I would be interested to see if anyone has examples of large scale CF apps running on ORM and if they can offer any insight into the pros and cons.