ORMScanner CFBuilder Extension

This post is more than 2 years old.

I've been doing a lot with ColdFusion 9 and ORM lately and I've run into an interesting little problem. Look at the code block below and see if you can find the error(s):

component persistent="true" table="ARTISTS" { property name="id" fieldtype="id"; property name="firstname" dbtype="string"; property name="lastname" dbtype="string"; property name="address" sqltype="string"; property name="city" sqltype="string"; property name="state" sqltpye="string"; }

There are three things wrong with this code, but CFBuilder will not flag any of them. Nor will ColdFusion complain when you use the entity. So what's wrong?

cfproperty (along with a few other tags) are "magic" within ColdFusion. By magic I mean that they allow you to pass any and all arguments. I could have easily used ray="fat" to the cfproperty tags and it would compile just as nicely. Normally this isn't such a big deal, but ORM adds something like 50(!!) new arguments that have special meaning to cfproperty. With so many new arguments it is easy to make a mistake.

The first thing I did wrong above was to use dbtype. ORM lets you specify either a generic database type (ormtype), or a specific type. When I began writing the code above I thought the specific argument was dbtype. But in reality, it is sqltype. My code wouldn't throw an error, and since I was using the default anyway it wouldn't be a huge big deal, but as you can guess, such a mistake could end up with unexpected results.

The second issue is more subtle. Notice the typo? I said sqltpye instead of sqltype. Again - this is not something that would throw an error in ColdFusion or be flagged in CFBuilder. So what I did was to create a new extension called ORM Scanner. ORM Scanner will scan all your ORM entities and compare the arguments to your cfproperty tags against the ginormous (that's a technical term) of "accepted" ORM attributes. Given the CFC above, here is the result.

Is this useful? I've attached the extension below. I'll be posting it to RIAForge a bit later today.

Download attached file.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Archived Comments

Comment 1 by Will posted on 3/24/2010 at 4:59 PM

Nice. I'm making typos like that alot, and without the IDE flagging them up, you could spand ages figuring it out. I like that it's easy to knock up these extensions in builder, and suspect that will end up being it's biggest strength

Comment 2 by inj posted on 3/24/2010 at 6:00 PM

Can not install this extension. Get an error: "Installation Error: null".
What I'm doing wrong?

Comment 3 by Raymond Camden posted on 3/24/2010 at 6:02 PM

Are you using CFB Final? Ah - I think I know what it is. I zipped it wrong. Unzip it, and then use the IMPORT option, not the install option. Import lets you point to a folder.

Comment 4 by inj posted on 3/24/2010 at 6:20 PM

No, I'm still using the last RC. Import was successful. Thanks for extension! :)

Comment 5 by John Allen posted on 3/24/2010 at 6:42 PM

This is really awesome. Really awesome time saver. Thanks mucho.

Comment 6 by Terrence Ryan posted on 3/25/2010 at 2:47 AM

The extension zip problem finally prompted me to blog about this issue: http://www.terrenceryan.com...

Comment 7 by Kevin Roche posted on 4/28/2010 at 12:03 PM

I can't find this on RIA Forge has it been removed or am I missing something?

Comment 8 by Raymond Camden posted on 4/28/2010 at 3:10 PM

I never posted it. I was supposed to, wasn't I?

Comment 9 by Raymond Camden posted on 6/17/2010 at 3:31 PM

Forgot again. Here we go:


Comment 10 by Kevin Roche posted on 6/17/2010 at 5:01 PM

Ray, Thanks for that. I want to use it for my CFUG presentation this month.