3. Extension to Criteria API

Criteria API has provided an alternative means to string-based JPQL to execute a query. However, JPA 2.0 specification has not explicitly specified any equivalence between a dynamically constructed CriteriaQuery and a JPQL string. OpenJPA provides a mechanism to convert a CriteriaQuery to an equivalent JPQL query string via the extended OpenJPACriteriaQuery API.

public interface OpenJPACriteriaQuery extends CriteriaQuery {
    /**
     * Gets equivalent JPQL String for the given CriteriaQuery.
     */
    public String toCQL();
}