Doug Hughes blogged today about an interesting new API he's working on for inline dynamic database abstraction. The current name of the project is Reaction, but it appears as though he may rename the project.
In a nutshell, this API creates Beans, Gateways, DOAs and Transfer Objects for you on-the-fly. Here's a quick snippet from Doug's post:
<cfset myDb = CreateObject("Component", "reaction.reactionFactory").init("scratch", "mssql", "/scratch/data", "development") />
The init method of the ReactionFactory accepts these arguments:
DSN - This is the name of the ColdFusion DSN which will be used to access the database.
DbType - This as a string indicating the type of database which is being accessed. Currently the only option is "mssql" for Microsoft SQL server. More will be added in the future.
GenerationPath - This the mapping you created to the directory where code will be generated.
Mode - This controls the generation behavior of Reaction. Options are always, development and production. Always causes objects to always be regenerated. Development causes objects to be regenerated if the database structure has changed. Production causes objects to never be regenerated unless they don't exist on disk.
The ReactionFactory currently has four public methods (in addition to init):
createBean(name) - This creates a bean object. More on this in a second.
createGateway(name) - This creates a gateway object.
createDao(name) - This creates a data access object.
createTo(name) - This creates a transfer object.
For each of these methods, the name argument is the name of the table in the database. For the most part, I believe developers will be using the createBean() and createGateway() methods more than the others.
Beans are quite cool. They're not quite exactly your traditional beans. They have load(), save() and delete() methods.
Sounds like an interesting project. I'll be interested to see how this thing develops.