Apache Torque

Apache Torque
Developer(s) Apache Software Foundation
Stable release
4.0 / February 27, 2013 (2013-02-27)
Written in Java
Operating system Cross-platform
Type Object-relational mapping
License Apache License 2.0
Website http://db.apache.org/torque/

Apache Torque is a sub project of the Apache Software Foundation Database Project. It is an object-relational mapper for Java. 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 document and DTD describing the database schema (which can either be written by hand or generated from an existing database). The same XML documents can also be used to generate and execute a SQL script which creates all the tables in the database. These generation steps are performed through the Velocity templating engine.

As Torque hides database-specific implementation details, Torque makes an application independent of a specific database vendor, if no exotic features of the database are used. A single XML document and DTD represents the overall schema, with platform-specific tailoring provided by Velocity templates and platform-specific XML where needed. This platform-specific component may be only around a tenth of the overall source volume, a useful saving when supporting multi-platform products.[1]

Usage of autogeneration eases the customization of the database layer, as you can override the autogenerated methods and thus easily change their behaviour. This allows for both rapid prototyping and easier long term maintenance of an application's database layer.

Torque's use of the XML document and DTD is rather unusual in the XML world, as rather than using a single fixed XML schema (or doctype) for all "Torque schema definitions" and keeping the application schema entirely within the XML document, Torque instead uses the DTD to represent the table / column mappings and the XML document is only used to describe application data. This permits Torque to use XML validation to validate the "data" component against the "schema" component of the target application. However it also means that schema generation, schema auto-documentation and schema authoring must work with the less familiar DTD syntax, rather than XML. In particular, this prevents XSLT being applied to a Torque schema in a useful manner.

History

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.

See also

References

  1. In-house system, of around 150 tables supporting three database platforms. Data volume of the XML is 180kb for the shared part, 60kb total for the three custom platforms.

External links

This article is issued from Wikipedia - version of the 4/11/2013. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.