Search Blog

Recent Comments
Re: Stats plugin ported to Model-Glue (by J.mihai at 12/14 8:52 AM)
Re: CFC DAO Generator (by rui at 7/04 5:42 AM)
Re: Updates to the DAO, Bean and Gateway generator (by rui at 7/04 4:49 AM)
Re: CFC DAO Generator (by fwscott at 6/22 7:03 PM)
Re: CFC DAO Generator (by dan at 6/22 12:38 PM)
Re: Trip to Thailand (by fwscott at 3/27 2:10 AM)
Re: CFC DAO Generator (by fwscott at 3/27 2:03 AM)
Re: CFC DAO Generator (by Garry Harstad at 3/26 12:30 PM)
Re: Trip to Thailand (by Niqui Merret at 3/23 4:51 PM)
Re: Adding a blogger ping utility to BlogCFM (by fwscott at 2/20 9:01 PM)
Categories
Annoucements (1 entries)
BlogCFM (3 entries)
CFC Generator (5 entries)
Coldfusion (11 entries)
Fusebox (2 entries)
Greasemonkey (1 entries)
Misc (3 entries)
Archives
November 2005 (2 entries)
October 2005 (1 entries)
August 2005 (1 entries)
July 2005 (4 entries)
June 2005 (5 entries)
May 2005 (7 entries)

Powered by
BlogCFM v1.01

June 2005
Updates to the DAO, Bean and Gateway generator
Post a Comment
After a few suggestions coming by the way of emails, I decided to put them into the distribution of the CFC DAO, Bean and gateway creator for Coldfusion MX 6/7 . Also, it should correctly work with Microsoft SQL server.

Changes:
  1. Bean's setter functions now have two additional optional arguments: isNull and Validate
  2. Now the bean controls the length of fields and if something is nullable.  Initially the generator will create the configuration for you but you can modify later by changing the setBeanConfig() function inside the bean CFC.
  3. The bean setter functions perform validation on the data passed in according to the specs from bean config.
  4. Each property of the bean has an isNull{property name} function
  5. All data coming from the database is considered trusted and will not be validated when passing it back to the bean setters.
To see the changes in action, view the demo.

You can download it here. The downloadable version contains a transformsbasic directory that contains the original transforms.

I am not sure I will put any other changes in the distribution as other suggestions were more specific and could be implemented in other ways.  But, remember you can incorporate your changes just by modifying the XSL files.  If you need some help, just contact me via the email address in the readme file.
Posted by fwscott at 12:44 PM | Comments (35)
 
Subscription Options

You are not logged in, so your subscription status for this entry is unknown. You can login or register here.

Re: Updates to the DAO, Bean and Gateway generator
Man, I love this generator! I've added in some functionality so that it will also generate a generic form for add/update. I've also linked up with the xslsl so that it will capitalize the first letter in get accessor/mutator functions so it's setId instead of setid. I'm picky like that :)

I had never played around with xlst before and had no idea you could do some of the incredible things you're doing with it. Thanks for the code!

Oh, I also figured out that the generator didn't handle BigInt's, so I modified the cfswitch statement in the field.getFieldArgType function:

Posted by Marlon on August 3, 2005 at 11:46 AM

Re: Updates to the DAO, Bean and Gateway generator
well, I guess it didn't like the code in that last message:

cfcase value="2,4,5,-5,6,-6,8"> cfset cfargtype = "numeric"> /cfcase>

cfcase value="93"> cfset cfargtype = "date"> /cfcase>

cfcase value="-1,1,12"> cfset cfargtype = "string"> /cfcase>

cfcase value="-7"> cfset cfargtype = "boolean"> /cfcase>

cfcase value="-4"> cfset cfargtype = "binary"> /cfcase>

cfdefaultcase> cfset cfargtype = "any,#getfieldtype()#"> /cfdefaultcase>

Posted by Marlon on August 3, 2005 at 11:49 AM

Re: Updates to the DAO, Bean and Gateway generator
Thanks for the update, I will get that included in the downloadable version. I didnt know you could do all the things you can do with XSL until I started developing this. Mind sending me that XSL you used to capitalize the first letter?

fwscott and the "at sign" comcast.net

Posted by fwscott on August 3, 2005 at 5:36 PM

Re: Updates to the DAO, Bean and Gateway generator
Hi,

These are the changes I had to make to get primary keys in postgresql 8 to work and to get anything to work for oracle:

Posted by Robsky on August 15, 2005 at 7:22 AM

Re: Updates to the DAO, Bean and Gateway generator
Right - that didn't work as well as I hoped. I'll post the patch to Francis.

Posted by robsky on August 15, 2005 at 7:23 AM

Re: Updates to the DAO, Bean and Gateway generator
Hiya, I really like the CFC Generator you've built! I've looked at a few free ones and this one generates code that I can understand and dosen't force any other practises on you. The only hiccup I've found so far is that I think it's not generating a boolean null for it's CFC's. I added to my CFC's and it all sprang to life.

Thanks!

Barny

Posted by barny on September 6, 2005 at 9:55 AM

Re: Updates to the DAO, Bean and Gateway generator
Sorry, that should be: < cfset variables.BooleanNull = "" />

Posted by barny on September 6, 2005 at 9:56 AM

Re: Updates to the DAO, Bean and Gateway generator
Thanks Barney, soon there will be a new release with various fixes that people have found and either posted here or emailed me. I will make sure this is included as well.

Posted by fwscott on September 6, 2005 at 7:25 PM

Re: Updates to the DAO, Bean and Gateway generator
I'm getting this error: Query Of Queries runtime error. Comparison Exception: While executing "=" Unsupported Type Comparison Exception: Comparator operator "=" does not support comparison between following types: Left hand side expression type = "LONG". Right hand side expression type = "STRING". The error occurred in C:\CFusionMX7\wwwroot\cfccreator\table.cfc: line 185 Called from C:\CFusionMX7\wwwroot\cfccreator\table.cfc: line 149 Called from C:\CFusionMX7\wwwroot\cfccreator\table.cfc: line 12 Called from C:\CFusionMX7\wwwroot\cfccreator\index.cfm: line 52

183 : select * from indexqry 184 : WHERE 185 : NON_UNIQUE = #PreserveSingleQuotes(comparestrprimary)# 186 : 187 :

Posted by Jason Lim on September 20, 2005 at 5:12 PM

Re: Updates to the DAO, Bean and Gateway generator
Great tool! All it needs is a form generator, like what Marlon said he had done in his comment. I love how it's database type independent... as it should be. I have seen other tools that only work in SQL Server. Another interesting upgrade would be a stored procedure generator/user, although that might be a little bit harder to implement.

Posted by Brian Meloche on September 21, 2005 at 12:43 PM

Re: Updates to the DAO, Bean and Gateway generator
Hi there, I've been using this for ages with MSSQL and it works great. However I seem to have found a glitch with MySQL. When it reads the date field in the summary it displays it fine however in the code it says the following:

Which actually reflects throughout all the code and causes various problems. Just thought I'd mention it, feel free to ignore me. ;)

Posted by Jeff on October 3, 2005 at 7:41 PM

Re: Updates to the DAO, Bean and Gateway generator
I'm getting same error as Jason Lim on September 20th. Did this get resolved? If so, how?

Posted by Chris Tilley on December 5, 2005 at 10:23 AM

Re: Updates to the DAO, Bean and Gateway generator
Congrats for this great time saver CFC DAO generator. Please answer one question: our appl haves several tables with several PK and FK(until 7!!!!). CFCCreator works for this type of model? Thanx in advance.

Posted by Marco Antonio C. San on February 22, 2006 at 6:27 AM

Re: Updates to the DAO, Bean and Gateway generator
Congrats for this great time saver CFC DAO generator. Please answer one question: our appl haves several tables with several PK and FK(until 7!!!!). CFCCreator works for this type of model? Thanx in advance.

Posted by Marco Antonio C. San on February 22, 2006 at 6:36 AM

Re: Updates to the DAO, Bean and Gateway generator
Hi Francis, I just started messing around with the generator, and the design patterns are right on the dot. So first of all, congrats, this is a great tool. I also found a particularity with MySQL 5.0 and above. The primary key that the jdbc drivers bring back in the index query for MySQL, set the NON_UNIQUE flag to true. Therefore, I had to switch the code around from:

TO:

This succesffully generated everything else. Hope this works

Posted by Luis Majano on March 7, 2006 at 1:10 AM

Re: Updates to the DAO, Bean and Gateway generator
Good to hear you were able to fix things Luis.

But I just wanted to let you know that there are some nice ORM tools for ColdFusion now that are being actively developed.

Take a look at http://www.remotesynthesis.com/blog/index.cfm/2005/12/6/Arf-ObjectBreeze-Reactor-and-More

None of these existed when I first created my tool... I dont even use my tool most of the time now.

Posted by fwscott on March 7, 2006 at 5:52 PM

Re: Updates to the DAO, Bean and Gateway generator
Thanks, Francis!! Which one do you recommend. I like the fact that I can customize the created code.

luis

Posted by lmajano on March 8, 2006 at 7:53 PM

Re: Updates to the DAO, Bean and Gateway generator
I have only tried Arf! and Reactor.

Reactor is basically a factory built on top of a .xsl generator like mine. This keeps all the Coldfusion generated files in a standard CF inheritance format.

Arf! generates files but the factory weaves the generated methods into a class.

I havent really done timing tests on Reactor since v.5 or so but in my initial tests, the more joins an object has, the slower it ran. However, Arf! seemed to always have a specific overhead but didnt increase like Reactor did. Reactor's slowdown at the time seemed to revolve around the amount of query objects that needed to be created.

In the end, my current big project I went with a heavily revamped version of Arf! but I may be changing this because Reactor seems to have an active community and Im thinking it will get more development attention than Arf! because Joe is really pushing MG 1.1/2.0.

To sum it up... I think both are great frameworks and if you want to go with something that currently has some drive to it, go with Reactor. If you want to go with something that has lots of room to tweak performance, go with Arf.

Posted by fwscott on March 8, 2006 at 8:32 PM

Re: Updates to the DAO, Bean and Gateway generator
Thanks Francis, will give them a try. As far as using the generated objects in your cfc creator, do you have any examples of the implementation?

Thanks

Posted by lmajano on March 9, 2006 at 6:52 AM

Re: Updates to the DAO, Bean and Gateway generator
Love your code generator, wish I knew about it earlier. I like yours much better than Arf or Reactor. I was able to customize it to produce just what I wanted and it now saves me at least 50% of my time. Thanks.

Posted by Don Blaire on June 16, 2006 at 3:27 PM

Re: Updates to the DAO, Bean and Gateway generator
This is way cool. Within a day I was able to move my master, detail, and editing forms into your xsl and it generates the forms. The only problem I am experiencing is that my forms contains the "space" html element. How can I preserve the spaces html element to display? Thanks.

Posted by Don Blaire on June 19, 2006 at 1:00 PM

Re: Updates to the DAO, Bean and Gateway generator
Glad you are liking it Don... When you say a "space" element, are you referring to nbsp; ?

Posted by fwscott on June 19, 2006 at 6:20 PM

Re: Updates to the DAO, Bean and Gateway generator
Yes, I am referring to nbsp;.

Posted by Don Blaire on June 19, 2006 at 7:55 PM

Re: Updates to the DAO, Bean and Gateway generator
you can try using....

<xsl:text disable-output-escaping="yes"<&:nbsp;</xsl:text>

not sure if my escaping will work or not... check out the link attached to the comment

Posted by fwscott on June 20, 2006 at 6:49 PM

Re: Updates to the DAO, Bean and Gateway generator
Thanks. I tried the suggestion and it worked one out of 6 times. Therefore I will use and search and replace with &;nbsp;. Thanks again.

Posted by Don Blaire on June 21, 2006 at 2:36 PM

Re: Updates to the DAO, Bean and Gateway generator
Great tool, I like the flexibility and speed of it; although there are a few bugs, but reading through the comments I was able to apply all the fixes. One thing though that I haven't seen it mentioned is that when I ran it on my dev machine (ubuntu linux) it complained about not being able to find the xsl files... This was due to some "/"s here and there. Once I corrected them on the index.cfm it all went smoothly. I know it's just a small deatail but you could add a bit of code to obtain the file separator on the current file system and avoid this hassle.

But nevertheless I'm really loving this tool.

Posted by oscar arevalo on June 27, 2006 at 3:29 PM

Re: Updates to the DAO, Bean and Gateway generator
Great tool!

I found one thing in the create method of the XXXDAO_ Microsoft_SQL_Server.cfc where it generates the NULL values null="#arguments.xxx.isNullxxx()#" the arguments.X does not match the argument that's referenced/passed in - i.e. comes out as arguments.category - when the argument that is passed in is called categoryBean.

I'm sure you know of this already - !

kp

Posted by Kevin Penny on June 29, 2006 at 2:33 PM

Re: Updates to the DAO, Bean and Gateway generator
Ok - ignore my last comment - when looking into the source I see that the 'Bean' is there - so i'll try and regenerate it and see if it does that again.

Posted by Kevin Penny on June 29, 2006 at 2:36 PM

Re: Updates to the DAO, Bean and Gateway generator
OK - so it wasn't just me - Line 28 (character 433) of createcrud.xsl didn't have the 'Bean' keyword after it - I've changed it in the xsl file and all should be golden!

Posted by Kevin Penny on June 29, 2006 at 2:39 PM

Re: Updates to the DAO, Bean and Gateway generator
The cfc creator is great but i was wondering about the gateway side of things. I notice it is instantiating an object for each row in the recordset, and this is incredibly slow to run.

I am building a system which has recordsets which need return 50,000 + records, and page though them. Gateways, as an array of objects is incredibly slow.

How does anyone else deal with this issue (apart from returning a query which I don't really want to do).

Posted by Puc Covelli on July 17, 2006 at 8:40 AM

Re: Updates to the DAO, Bean and Gateway generator
Im not an expert on this but would you need to get all 50,000 records at once? If not, you could add two parameters to your gateway functions... maybe startID and maxRecords. Then your service layer or whatever could handle the paging for you.

Or create some type of Iterator (maybe cached so the database only gets hit once) that loads a query and lazy loads the object as they are displayed. Then you could iterate through the objects as needed but if the page request only displayed 100 at a time, it would only create 100 objects. Perhaps even implement object pooling for the iterator so only one bean will ever exist and gets repopulated once the "next()" is called on the iterator.

Posted by fwscott on July 17, 2006 at 6:13 PM

Re: Updates to the DAO, Bean and Gateway generator
I noticed you are using several 'evaluates'...it looks to me like you could eliminate most of them (although not the one for the setter functions) by simply accessing the structures differently. For example:

<cfreturn evaluate("variables.beanconfig.#arguments.BeanConfigValue#") >

could be:

variables.beanconfig[arguments.beanConfigValue]

Posted by Joe FitzGerald on August 12, 2006 at 5:48 PM

Re: Updates to the DAO, Bean and Gateway generator
For sure Joe!

The things that old(er) code shows ;)

However, the xsl included is really for showing what can be done... not really what should be done. Customize it however you like.

Posted by fwscott on August 13, 2006 at 9:32 AM

Re: Updates to the DAO, Bean and Gateway generator
Hey there, I'm hoping you can provide some insight. I downloaded the CFCcreator this week and have been playing with it on CF 6.1 with my SQL Server database. The first few tables it created just fine. Most other tables tho, are returning this error:

Query Of Queries runtime error. Unsupported type comparison. The error occurred in C:\CFusionMX\wwwroot\cfccreator_original\cfccreator\table.cfc: line 185 Called from C:\CFusionMX\wwwroot\cfccreator_original\cfccreator\table.cfc: line 12 Called from C:\CFusionMX\wwwroot\cfccreator_original\cfccreator\index.cfm: line 52 Called from C:\CFusionMX\wwwroot\cfccreator_original\cfccreator\table.cfc: line 185 Called from C:\CFusionMX\wwwroot\cfccreator_original\cfccreator\table.cfc: line 12 Called from C:\CFusionMX\wwwroot\cfccreator_original\cfccreator\index.cfm: line 52

183 : select * from indexqry 184 : WHERE 185 : NON_UNIQUE = #PreserveSingleQuotes(comparestrprimary)#

At first I thought it was one of my customizations (I mucked with the XSL files a little) but after reinstalling from the original .ZIP, it was still doing it. If you have any advice (or can just point me to the line in the README that I skipped *g*) that'd be a big help.

Cheers. -Nolan

Posted by Nolan on October 14, 2006 at 2:15 AM

Re: Updates to the DAO, Bean and Gateway generator
I've got this error. Any one knows what this means?? I try changing the type but it still go down to the same problem.

The argument BEAN passed to function update() is not of type test2.CFC.MCQ_QNS

Posted by rui on July 4, 2007 at 4:49 AM

Name:   Required
Email:   Required your email address will not be publicly displayed.

Want to receive notifications when new comments are added? Login/Register for an account.

Anti-spam key

Type in the text that you see in the above image:

Your comment:

Sorry, no HTML allowed!