Somebody who read the Rolle article just asked me about how Castor compares to Torque in terms of object-relational mapping.  I did not know about Torque when I started Roller.  Torque looks really cool.  Here are my off-the-cuff thoughts on Torque vs. Castor:

  • With Torque, you start out with an XML file that defines your tables and relationships.  Then Torque generates both a set of objects for each of your tables and database creation scripts for creating the tables within a variety of databases.
  • Castor assumes that you already have your Java objects and you database tables.  So, you need to provide mapping from objects to tables - this is the mapping.xml file that I discuss in the Roller article.
  • With Torque, the objects know to write themselves to the database.  But with Castor, Castor itself knows how to do that. So, with Castor the objects can be dumb data holders.
  • Also Castor has the XML binding built in and Torque does not. The Castor mapping file can be used to define how objects map to database tables and how they map to XML.  I use this in Roller to allow the export/import of user weblog data to an XML file for backup purposes.
  • I have heard that Castor has object caching and Torque does not. I'm not sure how important this is.

I was out of town this week so I did not get to announce that the Roller article is online at O'Reilly's OnJava website.  Here is a direct link to the article, it is called Building an Open Source J2EE Weblogger.  I Hope you enjoy it and you will send any questions and comments my way.

Main | Next day (Apr 20, 2002) »