ActiveRecord with Transfer ORM

Posted on Dec 14, 2007

Sean Corfield's recent comment on a post by Peter Bell turned on a light bulb in my head this morning. Basically, his comment was that a decorated bean in Transfer ORM already has access to the Transfer framework. What this means is you can easily access any of the functionality of Transfer from within the decorator.

Let's look at an example of what this allows you to do. Now, I will preface this by saying that I am not a big fan overall of the ActiveRecord pattern, but let's say you wanted your bean to know how to persist itself... Well, you can implement that in exactly three lines of code within your decorator.

<cffunction name="save" access="public" returntype="void" output="false">
<cfset getTransfer().save(this) />
</cffunction>

Now all you need to do is something like bean.save() and your object, along with all its relevant relationships (i.e. hasMany, hasOne, etc.) will be persisted.

Thanks for the tip Sean!

Comments

Simeon Bateman And thereby bring the ActiveRecord/DAO bastardization from reactor to Transfer. You are gonna give Transfer an identity crisis. :)

Posted By Simeon Bateman / Posted on 12/14/2007 at 10:20 AM


Joshua Curtiss Sweet! Easy and effective for getting Active Record in Transfer! I've been studying your CFC Composition posts over the last couple days, and watched a Transfer preso by Mark, trying to grok it all. I always preferred Reactor and Active Record pattern at a theoretical level (without ever using either Reactor or Transfer... I just mean that's the slant I got when reading everything), but now as I get ready to actually start coding some stuff, I see the down side to implementing an Active Record pattern, even in a Transfer decorator. It ties your bean to the ORM by overstepping the service.

Interesting, nonetheless!!

Posted By Joshua Curtiss / Posted on 12/14/2007 at 12:36 PM


Write your comment



(it will not be displayed)





About

My name is Brian Rinaldi and I am the Web Community Manager for Flash Platform at Adobe. I am a regular blogger, speaker and author. I also founded RIA Unleashed conference in Boston. The views expressed on this site are my own & not those of my employer.