Photo from Chile

A Base Persistent (ORM) Object for CF9

I've been doing some experimentation with ColdFusion 9's Hibernate (ORM) integration, part of which involved creating a Base Persistent Object.

What is a Base Persistent Object?

I'm using the term persistent object to refer to a ColdFusion 9 cfc that has a persistent="true" attribute. That is, a component that is used to create objects that will be persisted to a database via Hibernate, using CF9's ORM integration. These are variously referred to as persistent objects, ORM objects, entity objects, etc. There are certain behaviours that I want all of my persistent objects to have, and I have found that the best way to achieve this is to create a base persistent object and then have all of my concrete persistent objects extend that base object.

Behaviours contained in the Base Persistent Object

The behaviours that I'm including in my Base Persistent Object allow any object that extends it to:

  • populate itself from user-submitted data
  • save itself
  • delete itself
  • validate itself
  • inject dependencies into itself via Coldspring

As CF9 is still in beta, this object is obviously in flux. I am planning on releasing the code for the object as open source, and have set up a project at BasePersistentObject.riaforge.org for that purpose. I hope to have a 0.1 version available shortly, at which point the code will be available for download via the project page.

TweetBacks
Comments
I'm intrigued. Be sure to comment on this post when the code is up!
# Posted By Shannon Hicks | 8/31/09 12:06 PM
I'm subscribing to the comments as well, looking forward to see what you have come up with so far :)
# Posted By Justin Carter | 8/31/09 1:17 PM
Get Funky Bob.

(I'm subscribing for comments)
# Posted By Dan Wilson | 8/31/09 3:31 PM
Interesting! Subscribing for comments.
# Posted By Rupesh Kumar | 9/1/09 5:39 AM
Looking forward to it Bob.
# Posted By John Allen | 9/1/09 12:10 PM
I have now released a Simple Base Persistent Object (BPO) at the RIAForge site, and have published a new blog post about it.

Unfortunately I was not able to find the time to properly test and document my full-featured BPO, which includes dependency injection and validation, but I do plan to do that in the future. It probably won't be until after CFinNC though. :-(

If I can squeeze it in I may try to release the code without any accompanying documentation and explanation, which I imagine would be enough for those of you who are interested.
# Posted By Bob Silverberg | 9/7/09 9:45 PM
I would be very interested in your full-featured BPO, specifically for dependency injection. Does CF 9 play well with ColdSpring?
# Posted By David | 9/17/09 2:57 PM
I've had no problems using Coldspring with CF9 to date. I will endeavour to make the full-featured BPO available soon, but it may be a few weeks.
# Posted By Bob Silverberg | 9/17/09 3:52 PM