A Base Persistent (ORM) Object for CF9
Posted At : August 31, 2009 10:05 AM | Posted By : Bob Silverberg
Related Categories: ColdFusion, CF ORM Integration, BPO
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.
(I'm subscribing for comments)
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.