What is Torque?

Apache Torque is an object-relational mapper for java. In other words, Torque lets you access and manipulate data in a relational database using java objects. Unlike most other object-relational mappers, Torque does not use reflection to access user-provided classes, but it generates the necessary classes (including the Data Objects) from an XML schema describing the database layout (which can either be written by hand or generated from an existing database). The XML schema can also be used to generate and execute a SQL script which creates all the tables in the database.

As Torque hides database-specific implementation details, Torque makes an application independent of a specific database if no exotic features of the database are used.

Usage of autogeneration eases the customization of the database layer, as you can override the autogenerated methods and thus easily change their behaviour.

Torque was developed as part of the Turbine Framework. It is now decoupled and can be used by itself. Starting with version 2.2 Turbine uses the decoupled Torque.

Elements of Torque

Torque consists of multiple parts:

The Torque runtime contains everything to allow an application to access the database. It is the only component of Torque needed in your application and can be used standalone.
The generator contains ant tasks which do all the work for the Maven plugin. If you use the Maven plugin, you do not need to use the generator directly. However, the generator can also be invoked directly using ant.
The Maven plugin creates the O/R peer and object classes for accessing and storing data from the database. It can also generate the XML description of an existing database and (in reverse) create an SQL script to create the tables in the database. Internally, the Maven plugin uses the generator to accomplish these tasks.
The templates contain the building blocks used by the generator to create the O/R peer and object classes, SQL scripts and the like. You can change the templates if you want to customize the output of the generator (this is only necessary in very special circumstances). Up to release 3.1.x, the templates were a part of the generator. Starting with the 3.2 release of Torque, the templates have been separated into their own jar archive.
Village is a 100% Pure Java API that sits on top of the JDBC API. The purpose of this API is to make it easier to interact with a JDBC compliant relational database.


  • Most recent production release of Torque is Torque 3.3
  • Most recent production release of the Village component of Torque is Village 3.3.1
  • Most recent development release of Torque is Torque 4.0-beta1

The Apache Software Foundation

Torque is an Apache project, and is part of a larger community of developers and users.

Apache Torque, Torque, Apache, the Apache feather logo, and the Apache Torque project logo are trademarks of The Apache Software Foundation.