If we are creating the first query after the server start-up with the criteria-api every following query crashes with a ClassCastException "org.apache.openjpa.util.StringId cannot be cast to com.provinzial.entity.EntityA".
If the first query is a named-query with "normal" JPQL there is no problem using both, the named queries or the queries created by criteria-api.
We've got an Entity-A having a one-to-many relation to Entity-B. Entity-B has to be loaded eager. The problem doesn't exist if Entity-B is loaded lazy.
A workaround is to fire a JPQL-Query of a "dummy Entity-A" at the server start-up, but this is not a nice solution...