Tuesday, January 30, 2007

Transfer ORM

ORM stands for object relational Mapping. I am not sure I understand everything it does yet but I do know that it automatically creates CRUD DAO objects. I use to spend hours writing beans, DAO's and gateways. Well, Transfer does the beans and DAO's automatically and even some of the simple gateway queries.

Previously I had been using http://rooibos.maestropublishing.com/ to generate beans and then I would cut and past generic DAO code for the CRUD methods. CRUD stands for Create-Read-Update-Delete. The standard things you do to an "object" or row in a database.

Setup is probably the most difficult, as anything else, especially the first time you attempt it. In Transfer you have to download the open source code from: http://www.compoundtheory.com/?action=transfer.download or you can get the latest BER (Bleeding Edge Release) via SVN at http://svn.riaforge.org/transfer .

You place this code in your root directory. You will then have a "transfer" directory under web root.

you need to initialise the transfer object, which I did for my test in my application.cfc file. You can just do it on a page if you want. You can get further instructions here: http://www.compoundtheory.com/?action=displayPost&ID=112. This page also offers examples of using Transfer for the basic CRUD operations.

Once you define your datasource and your table in datasource.xml and transfer.xml. It is this easy to get a row from the database:

transfer.get("user.user", userid).

Want a query of all users:

transfert.list("user.user")

It took me about as much time to figure out how to use the basics of transfer as it would have to generate all the DAO, Bean and simple Gateway methods for 1, maybe 2 projects, but now I can save my self tons of time not having to create those anymore.

I am amazed at the creators of such "frameworks" as transfer. They are wicked smart and provide a real value to me. Thanks to Mark Mandel and any others who devote their time and smarts.

No comments: