Apache Torque
Encyclopedia
Apache Torque is a sub project of the Apache Software Foundation
Apache Software Foundation
The Apache Software Foundation is a non-profit corporation to support Apache software projects, including the Apache HTTP Server. The ASF was formed from the Apache Group and incorporated in Delaware, U.S., in June 1999.The Apache Software Foundation is a decentralized community of developers...

 Database Project. It is an object-relational mapper for Java
Java (programming language)
Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...

. Torque lets you access and manipulate data in a relational database
Relational database
A relational database is a database that conforms to relational model theory. The software used in a relational database is called a relational database management system . Colloquial use of the term "relational database" may refer to the RDBMS software, or the relational database itself...

 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
Document Type Definition
Document Type Definition is a set of markup declarations that define a document type for SGML-family markup languages...

 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.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.

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
XML Validation
XML validation is the process of checking a document written in XML to confirm that it is both "well-formed" and also "valid" in that it follows a defined structure. A "well-formed" document follows the basic syntactic rules of XML, which are the same for all XML documents...

 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
XSLT
XSLT is a declarative, XML-based language used for the transformation of XML documents. The original document is not changed; rather, a new document is created based on the content of an existing one. The new document may be serialized by the processor in standard XML syntax or in another format,...

 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

  • Object-relational mapping
    Object-relational mapping
    Object-relational mapping in computer software is a programming technique for converting data between incompatible type systems in object-oriented programming languages. This creates, in effect, a "virtual object database" that can be used from within the programming language...

     (ORM)
  • List of object-relational mapping software
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK