Note: This blog post is from 2006. Some content may be outdated--though not necessarily. Same with links and subsequent comments from myself or others. Corrections are welcome, in the comments. And I may revise the content as necessary.I'd like to put out for consideration by the CFML community a possible new approach for object-relational mapping (ORM), using an existing Apache project called IBATIS as a model. I'm wondering if someone may want to consider implementing a CFML version of it for a new ORM approach in CFML.
IBATIS, at http://ibatis.apache.org/ is an alternative ORM approach based on a concept of SQL Maps, which in essence are simply SQL statements stored in XML files with a well-defined API for mapping and manipulating those in your app. The approach does not generate SQL for you, but rather is intended to serve as a means to segregate to XML files--and manage via an API--the SQL that may already exist substantially for existing apps or for new apps that may simply require some hand-coding of SQL. (The last sentence added after some comments suggest that this point made later in the post was missed.)
The benefit is that since CFML folks are already knee deep in SQL, it brings a measure of architecture without completely detaching them from the SQL they know and love (or at least tolerate).
If that sounds counter to other ORM approaches, which often generate the SQL automatically and/or intentionally hide it from you, that's because it is quite different. I'll grant that there are many who would benefit from having an architecture remove SQL from their control. It's just that this seems an alternative worth considering.
I certainly don't mean to knock at all the other CFML-based ORM implementations that exist already (such as Arf, ObjectBreeze, Transfer, and Reactor). Each approach has its place and pros/cons. As the other CFML-based ORM frameworks tend to be based on existing approaches from other platforms, I'm merely pointing out this alternative as a possibly useful model.
I'm also not offering here my own new CFML-based implementation based on IBATIS. But note that there are currently implementations for Java and .NET at the Apache site, so it shouldn't be tough for someone to leverage the Java implementation in CFML.
It strikes me that the IBATIS approach may be closer to the way fuseboxers and others segregate their queries into their own CFML file. Perhaps this approach of storing them in an XML file instead and using an API to access the results would offer a better though still somewhat familiar approach to abstracting queries.
I was sharing the idea with Sean Corfield at CFUnited last night, and he was intrigued. After I sat in on his excellent presentation on objects and persistence, we discussed it again and he had started looking into it overnight. Perhaps it could make it into FB 6? :-)
I'm hoping someone may want to take the ball and run with it. If you're intrigued, considering discussing it with Sean or take it on yourself, or just continue the conversation. Hope it proves helpful.
For more content like this:
- If you may prefer direct help, rather than digging around here/elsewhere or via comments, I can help via my consulting services
- See that for more on how I can help a) over the web, safely and securely, b) usually very quickly, c) teaching you as we go, and d) with satisfaction guaranteed