oqt-maven-plugin

The maven-oqt-maven-plugin provides the ability to validate and translate JPQL queries to SQL queries.

Why using this plugin

I'm quite a fan op JPQL, the query language is fairly simple and you don't have to worry about using the correct SQL joins. However, it has one flaw: you don't know what it actually executes and with large production databases you don't want to find out that OpenJPA secretly added a CAST AS VARCHAR(1000) to your queries. That's exactly why I created the oqt-maven-plugin: this plugin will analyze all your JPQL queries and transform them into the SQL queries that will be executed on your database.

How it works

This plugin uses the public and somewhat less public API of OpenJPA to transform a JPQL query to a SQL query. The translation is done by setting up a connection to a live database and capturing all the SQL queries before they are executed. By using a live database OpenJPA will translate the JPQL queries in the most realistic way by using the actual database metadata and by using the correct DB driver.

Besides the translation of JPQL queries, the plugin can also validate JPQL queries.

Goals Overview

The two main goals are oqt:report and oqt.validate.

  • short description for this plugin goal.

Usage

General instructions on how to use the oqt-maven-plugin can be found on the usage page.

In case you still have questions regarding the plugin's usage, please have a look at the FAQ and feel free to contact the user mailing list. The posts to the mailing list are archived and could already contain the answer to your question as part of an older thread. Hence, it is also worth browsing/searching the mail archive.

If you feel like the plugin is missing a feature or has a defect, you can fill a feature request or bug report in our issue tracker. When creating a new issue, please provide a comprehensive description of your concern. Especially for fixing bugs it is crucial that the developers can reproduce your problem. For this reason, entire debug logs, POMs or most preferably little demo projects attached to the issue are very much appreciated. Of course, patches are welcome, too. Contributors can check out the project from our source repository.

Examples

To provide you with better understanding of some usages of the oqt-maven-plugin, you can take a look at the usage page which includes some examples.