Nov 1 2005

Arf! 1.0e-23 (That's 0.00...001) bits

Posted by Joe Rinehart at 9:50 PM
11 comments
- Categories: ColdFusion MX | Model-Glue | Arf!

Seems like a lot of people want to test this, so, well, here's what I've got so far. It's pretty rough at this point, documentation is sparse, and there's some missing functionality, but this is an improvement on the version I Camtasia demo'd.

http://clearsoftware.net/client/enclosures/net.zip

The most notable API change is that hasMany() and belongTo() only have one required parameter: the name of the CFC you're relating to. Arf! assumes the last part of its name (that "last part" of my.app.Widget is "Widget") is the tablename it's relating to, and that the foreign/primary keys involved are named WidgetId.

In other words, instead of:

<cfset belongsTo("Widget", "my.app.Widget") />

It's just:

<cfset belongsTo("my.app.Widget") />

All of those assumptions can be overridden (as can table names, etc), but for now, you'll have to read some source to figure that out. Examples and docs will follow in time.

For now, feel free to e-mail me what breaks. Simeon Bateman is being kind enough to set up a Trac (trouble ticket) site for me, so I'll probably either fix what's broken, or e-mail you back asking you to fill out a ticket.

Comments

Cory Toth

Cory Toth wrote on 11/01/05 11:26 PM

I know this is pre alpha, but i did catch something that you might want to take a look at.

&lt;cfdump var=&quot;#widgetCategory.list(&quot;&quot;,&quot;name DESC&quot;)#&quot;&gt;

Will return and error because you are just checking if the argument is defined not if its defined and not empty.

Thanks for this excellent software.
Scott Stroz

Scott Stroz wrote on 11/01/05 11:35 PM

Anyone else getting the following error:

GenericJDBCMetadataFactory: Table WIDGETCATEGORY not found!

I have checked the code and DB about a dozen times and can't seem to find the issue(s).
Scott Stroz

Scott Stroz wrote on 11/01/05 11:42 PM

OK - got past that error...I transposed the values for ds.setDSN() and ds.setDatabase().

BTW - for Oracle 10g XE, I needed to use ds.setDatabase(&quot;&quot;).

Anyway, now I am getting the following error:

GenericJDBCMetadataFactory: Cannot use table WidgetCategory because it has no primary key(s)!
Cory Toth

Cory Toth wrote on 11/01/05 11:51 PM

Ensure your widgetCategoryID field is a primary key and either a type of integer or varchar(35).
SOSensible

SOSensible wrote on 11/01/05 11:51 PM

OK... this works inside my methodology with a couple of simple exceptions. One... the &quot;next&quot; method is missing. Simple... commented out those two lines and it worked fine.

Second... couldn't just put &quot;Widget&quot; or &quot;WidgetCategory&quot;... had to include the whole class path.

Third... changed this line...
&lt;cfset widgetCategory = rf.createRecord(&quot;com.my.app.WidgetCategory&quot;) /&gt;
to
&lt;cfset widgetCategory = rf.createRecord(&quot;net.clearsoftware.arf.test.WidgetCategory&quot;) /&gt;

This is a nice start. Looks like you got the jist of what is going on. Now when do we look at Trees (Hierrarchal Recordsets) and Lists? The trees are somewhere I would like to submit some code to make things super cool for doing fast data.

Can't wait to help auto generate rough forms also... this is right up my alley. Don't know how much I can help, or my ideas will be the community concensus, but this is something you got me to help on!
Scott Stroz

Scott Stroz wrote on 11/01/05 11:55 PM

In the MS SQL DB, the priamry key is WidgetCategoryID and is set to varchar(35).

In the Oracle DB, the primary key is WidgetCategoryID and is set to varchar2(35)...there was no 'varcahr' to choose from
Scott Stroz

Scott Stroz wrote on 11/02/05 12:01 AM

hmmmm...I set the primary key to INT and it processed past that error to:

Could not find the ColdFusion Component Widget.
Please check that the given name is correct and that the component exists.

The error occurred in C:websitesARF
etclearsoftwarearfRecordFactory.cfc: line 67
Called from C:websitesARF
etclearsoftwarearfActiveRecord.cfc: line 73
Called from C:websitesARF
etclearsoftwarearfActiveRecord.cfc: line 185
Called from C:websitesARF
etclearsoftwarearfRecordFactory.cfc: line 114
Called from C:websitesutilitiesarfarf.cfm: line 12

Line 12 of arf.cfm is:

&lt;cfset widgetCategory = rf.createRecord(&quot;arf.WidgetCategory&quot;) /&gt;
Scott Stroz

Scott Stroz wrote on 11/02/05 12:01 AM

Oh yea, and Widget.cfc resides in the same directory as WidgetCategory.cfc
Scott Stroz

Scott Stroz wrote on 11/02/05 12:10 AM

Whoo-hoo...cooking with gas now....kind of.

I got most everything working...now I get this error (after seeing the dumps of widgetcategory and widget)

The method 'makeRecord' could not be found in component C:websitesARF
etclearsoftwarearfRecordFactory.cfc.
Check to ensure that the method is defined, and that it is spelled correctly.

The error occurred in C:websitesARF
etclearsoftwarearfutilQueryIterator.cfc: line 60

58 :    
59 :    &lt;cfif getComponentName() neq &quot;net.clearsofware.arf.ActiveRecord&quot;&gt;
60 :       &lt;cfset record = rf.makeRecord(getComponentName(), &quot;&quot;, getTableName()) /&gt;
61 :    &lt;cfelse&gt;
62 :       &lt;cfset record = rf.createRecord(getTableName()) /&gt;
Scott Stroz

Scott Stroz wrote on 11/02/05 12:17 AM

Sorry to be such a pain.

In Oracle 10g XE, I updated the tables so that the primary keys for each table are 'number' (again, in teh web based GUI, there was no INTEGER to choose), and I am still getting the 'No primary keys' error.
Scott Stroz

Scott Stroz wrote on 11/02/05 7:22 AM

Figured out the error, thanx to a comment on another post.

Line 60 of QueryIterator,cfc reads:

&lt;cfset record = rf.makeRecord(getComponentName(), &quot;&quot;, getTableName()) /&gt;

I changed ti to read:

&lt;cfset record = rf.createRecord(getComponentName(), &quot;&quot;, getTableName()) /&gt;

And all is fine with the world.

Now here's a question. Can arf handle a many-to-many relationship?

Write your comment



(it will not be displayed)