Step 1: Obtaining the Torque Distribution

First of all, note that Torque is divided into three parts.

  • The generator generates your persistence classes from an xml description of the database. It also generates and executes sql scripts to create all the necessary tables, constraints etc. in your database. The generator comes packaged in two jars: The templates in torque-gen-templates.jar, and the rest in torque-gen.jar.
  • The maven plugin integrates the generator into Maven, a software project management tool.
  • The runtime has to be included in your projects for the generated classes to work properly.
For this tutorial, we will be using the maven plugin for Torque 3.2.x (which will silently invoke the generator) to generate our object model classes and the Torque 3.2.x runtime for our application that makes use of the generated classes.

If you have not already done so, download and install Maven. You then need to obtain the Torque maven plugin. The Maven Howto includes details of how to build the maven plugin from source, but you can easily install a binary distribution thus:

maven plugin:download -DartifactId=maven-torque-plugin -DgroupId=torque -Dversion=3.2-rc1

At runtime the generated object model classes need access to the Torque runtime distribution and associated libraries - these are available from the Downloads page (the file to download is torque-3.2-rc1.tar.gz or torque-3.2-rc1.zip, depending on your development platform). We will cover what to do with this file in a later step.

If you are using the maven plugin, you do not need to download the generator separately. The maven plugin will download the needed resources.

Where to next

Next we will look at Configuring Torque.