Transfer : First Thoughts

On June 15, 2008, in ColdFusion, by Anuj Gakhar

Having read the blogosphere about Transfer a lot recently, I wanted to give it a try as well. My only problem is that, at my work, I dont get to use Transfer because of the way things are setup there. So, I had to find the time to do it in my spare time outside of work which is a hard thing to do. However, I managed to do it recently.

For those who are not aware, Transfer is a ORM (Object Relational Mapper) for ColdFusion, that according to their website, through a central configuration file Transfer knows how to generate objects, and how to manage them and their relationships back to the database. Which means you don’t have to write any (almost!) SQL queries while writing your app. You need to map / define your database objects in a XML file and tell Transfer to read the file and voila! you are done. The best thing is , behind the scenes, it supports 4 databases (MS Sql Server 2000+, MySQL 4.1+, PostGres 8.1+, Oracle 9i+) which means your database could be any of the these 4 and as long as your config file is mapping the database correctly, you wont have to change any code if ever you decide to change your backend database server. That is a big flexibility!

So, after my initial reading of the docs and simple download and after creating a mapping in the CF admin to tell it where Transfer sits on my machine, I was all set. I created a simple config file for one of my databases. which looks like this.

[xml]

<?xml version="1.0" encoding="UTF-8"?>
<transfer xsi:noNamespaceSchemaLocation="transfer.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<objectCache>
<defaultcache>
<scope type="instance"/>
</defaultcache>
</objectCache>
<objectDefinitions>
<package name="Customers">
<object name="Customer" table="customers">
<id name="customer_id" type="numeric"/>
<property name="customer_name" type="string"/>
<property name="customer_telephone" type="string"/>
<property name="customer_email" type="string"/>
<property name="customer_active" type="boolean"/>
</object>
</package>
</objectDefinitions>

</transfer>

[/xml]

That basically tells Transfer that it should go and read a table called customers in my database and map its 4 fields to whatever properties I defined here.

And then in my CF code, after initiating Transfer factory, I can simply do this to get a list of all customers. (just as an example)

[xml]

<cfscript>
qCustomers = transfer.list(‘Customers.Customer’);
</cfscript>

[/xml]

And that gives me a query with all my customers. Sweet! I am very impressed. We can also create one to many and many to many mappings within the config file and Transfer will know how to relate the 2 tables. Very sweet!

I know this is just the beginning I think I am going to use it all over now. The only question popping my head is how would it perform in high traffic websites and if I can configure it to look for database objects with different logins e.g. a database could have tables with different ownerships (dbo, dev, mylogin etc), and some queries could have joins across these tables, so is this supported? Will find out soon after some more reading!

Great work here by Mark Mandel! (the guy behind the project, for those who dont know)

 

8 Responses to Transfer : First Thoughts

  1. Hi Anuj,

    Glad you’re taking a look at Transfer, it’s pretty powerful stuff.

    There is a recent article here on performance:
    http://www.ghidinelli.com/2008/06/14/on-transfer-and-performance/

    I was lucky enough to see Mark speak last week at WebDU. Transfer handles most SQL operations you would typically require including:
    – Order by
    – Where
    – INNER and OUTER JOINS

    Good luck with your reading 🙂

  2. cfsuman says:

    this site is nice and very helpful.
    here is an another nice site http://web-adobe.blogspot.com

  3. Anuj Gakhar says:

    @Michael, yes, I agree it is indeed pretty powerful stuff. I just hope it try and use it more in the future.

  4. […] Anuj Gakhar posts his thoughts about giving Transfer a try […]

  5. Chase says:

    This is helped me a ton..!!!

    Thanks 🙂

  6. Stephen Nutt says:

    I consider this day as lucky day for me. Thanks that I found out this blog post. Such a great help for my struggles.

    chiropractor Murfreesboro

  7. Is coldfusion still being used by many developers? I’d assume there’s a transition by many to .NET (LINQ) and things like Django with inbuilt ORM.

    Benedict Noel
    Founder, Zombal.com
    R&D Outsourcing

  8. It sounds like people have been helped a lot through this blog post. Although I am not very familiar with the topic, I share the sentiment of the others on a positive note. May more people who use Transfer be able to find this blog helpful.

    nathan anderson of Copywriting

Leave a Reply to Chase Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

© 2011 Anuj Gakhar
%d bloggers like this: