Build weakly-typed Criteria API

Details

Description

JPA 2.0 has introduced specification for weakly-typed (I prefer relaxed-typed) dynamic query construction a.k.a untypesafe Criteria API. The earlier draft version of JPA described a relaxed-typed dynamic query which had already been implemented in OpenJPA. However, this API had a short life span and now no more endorsed by the spec. Given that the API has been reasonably appreciated by the user community with its ease of use and we already have an implementation for it, that implementation is refactored into a OpenJPA specific 'Dynamic Query' API. The approach followed to implement this 'Dynamic Query' was completely decoupled from OpenJPA query infrastructure. The output was a pure JPQL string and that was the input to OpenJPA query. The approach had its advantage of a clean design at the cost of paying for parsing the JPQL query string again.

While it is possible to revert to that strategy for new relaxed-typed Criteria API but such strategy will force us to very dissimilar approaches (one for the strict-typed and the other for the relaxed-typed). Instead what I am proposing is to implement relaxed-type API on the basis of strongly-typed API implementation. Given that the strongly-typed API will require a meta-model, I feel we can devise a way for the relaxed-typed API to resolve as soon as possible the user input (String) to a proper type (Class). This will keep the implementation uniform.