Skip to main content

Apache Torque

Apache Torque is a Java-based object-relational mapping (ORM) and persistence layer framework (data access / Object–Relational Mapping (ORM)) that generates database access code from XML schema definitions.

  • Code generation of Java object model and Structured Query Language (SQL) mappings from database-neutral XML schema (code generation / ORM).
  • Abstraction layer for database access via generated peer and object classes (data access layer).
  • Support for multiple relational databases through configurable adapters (database portability).
  • Integration with Apache Maven-based build workflows for schema-driven code generation (build and tooling integration).
  • Customizable templates and configuration for tailoring generated persistence code (extensibility / customization).

More About Apache Torque

Apache Torque is a Java object-relational mapping (ORM) framework (data access / ORM) that generates database access layers from XML schema definitions, with the goal of separating database structure from application logic and reducing manual SQL and boilerplate persistence code.

The framework centers on a schema-first workflow in which developers describe the relational database model in an XML schema file. From this schema, Torque’s generator produces Java classes that model tables as objects, along with associated peer classes that encapsulate SQL operations. This approach supports a consistent mapping between relational structures and Java code and reduces the need for handwritten CRUD operations and query wiring.

Torque operates as an intermediate abstraction layer (data access layer) over relational databases. It uses database adapters to work with different Database Management Systems (DBMS), so the same schema can generate code targeting various supported relational databases with minimal changes. Generated classes handle tasks such as object creation, retrieval, updates, and deletes, while configuration properties and adapter definitions control connectivity and dialect-specific SQL handling.

In enterprise environments, Apache Torque is used within Java applications that require a code-generated persistence layer and a clear separation between database schema management and business logic. It integrates with standard Java build tools (build and tooling integration), in particular Maven-based builds, where code generation steps can be executed as part of the build lifecycle. This makes it suitable for projects that maintain database schemas under version control and rely on automated builds and deployments.

The project provides configuration options and template mechanisms (extensibility / customization) that allow teams to adjust how code is generated, including package structures, naming conventions, and additional behavior in generated classes. Because Torque is part of the Apache DB project space under The Apache Software Foundation, it follows the foundation’s governance and licensing model (open-source governance), including the Apache License, Version 2.0, which supports commercial and non-commercial use.

From a directory and taxonomy perspective, Apache Torque is categorized as a Java ORM and persistence framework (data access / ORM), with related roles in schema-driven code generation (code generation), database abstraction (database portability), and integration into Java enterprise build and deployment pipelines (application development tooling).