Description
It should be possible to set query hints in Java code, or in orm.xml, but it seems the orm:hint element is ignored.
The following two options should result in the same query:
- Java only:
em.createQuery("Select e from MyEntity e where e.type = 'literal'") .setHint(QueryHints.HINT_USE_LITERAL_IN_SQL, true) .getResultList()
- Named query
- Define the query and the hint in orm.xml
<named-query name="Query1"> <query>Select e from MyEntity e where e.type = 'literal'</query> <hint name="openjpa.hint.UseLiteralInSQL" value="true" /> </named-query>
- And then call the query without additional information
em.createNamedQuery("Query1") .getResultList()
- Define the query and the hint in orm.xml
However, (2) does not correctly take the query hint into account and thus literals are replaced with SQL positional parameters.