Step 1: Installing Maven and the Torque Maven Plugin

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. In other words, the maven plugin is a frontend for the generator.
  • 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 sql scripts. For working with the generated classes, we will use the Torque 3.2.x runtime for our sample application.

If you have not already done so, download and install Maven. It is highly recommended to use version 1.0.2 of Maven.

Maven uses the ibiblio maven repository to download any libraries and resources it needs. From there, obtain the Torque maven plugin by typing

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

You do not need to download the generator or the runtime separately. Maven will download them from the ibiblio distribution site automatically when they are needed.

Where to next

Next we will look at Configuring the Torque generator.

User Comments

User comments for this step