code: private String getQueryString(Query query) {
          Map<String, Object> hints = query.getHints();
          return hints != null ? (String) hints.get("query") : null;
      }
docs: 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.