This tutorial is intended to give first-time users an introduction to using Torque, an object-relational tool.
This will include how to obtain the Torque distribution, setting up a database, and writing a sample application to demonstrate the power of Torque. The tutorial is not meant to be an exhaustive introduction to Torque, please refer to the Torque documentation for more detailed information.
In this tutorial, it is assumed that you have experience in programming in Java, and that you have some experience using JDBC (e.g. you should know what a jdbc driver and a connection URL is). It is expected that you have a working installation of the JDK, Version 1.4 or higher. With versions less than that you will have to make sure you have the JDBC and JNDI jars available. Although Maven 1 is heavily used in this tutorial, it is not assumed that you have any experience in using it.
For each step in the tutorial, user comments are available in the Torque Wiki, see the links at the bottom of each page. If you had difficulties with a particular step and found a solution, please write it up and add it to the corresponding wiki page for each step.
If you are using Torque for the first time, you should
stick very closely to the example provided in the Tutorial,
and get the sample application running as is.
If you play around, there are quite a few places where
things can go wrong, and is not always clear why they go wrong.
Errors are much easier to find when you can pinpoint
the source of the error by
"Ok, it went wrong when I changed foo".
Once you got a running example, you can (and should) still play around to see whether Torque can satisfy your particular needs.
The example used throughout this tutorial is based on an email sent to the turbine-user mailing list by Steven F. Davis called torque outside turbine - detailed example (long). It has subsequently been updated for Torque 3.1 which separates the generator from the runtime and provides a Maven 1 plugin for executing the generator using Maven 1, and further been updated to reflect the changes in Torque 3.2 and Torque 3.3.
First we will look at Installing Maven 1 and the Torque Maven Plugin.