Exemplo n.º 1
0
 public void testHintsAreProcessed() {
   Query q = em.createNamedQuery("SQLWithHints");
   assertEquals(QueryLanguages.LANG_SQL, OpenJPAPersistence.cast(q).getLanguage());
   String hintKey = "XYZ";
   assertTrue(q.getHints().containsKey(hintKey));
   assertEquals("abc", q.getHints().get(hintKey));
 }
 private Query recreateQuery(Query current, String newSqlString) {
   Query result = entityManager.createQuery(newSqlString);
   for (Entry<String, Object> hint : current.getHints().entrySet()) {
     result.setHint(hint.getKey(), hint.getValue());
   }
   return result;
 }
 private Query recreateQuery(Query current, String newSqlString) {
   Query result = entityManager.createQuery(newSqlString);
   Map<String, Object> hints = current.getHints();
   for (String hintName : hints.keySet()) {
     result.setHint(hintName, hints.get(hintName));
   }
   return result;
 }
 /**
  * If the named query has the "query" hint, it uses the hint value (which must be jpa QL) to
  * create a new query and append to it the proper order by clause.
  */
 private String getQueryString(Query query) {
   Map<String, Object> hints = query.getHints();
   return hints != null ? (String) hints.get("query") : null;
 }