Example usage for javax.persistence Query getHints

List of usage examples for javax.persistence Query getHints

Introduction

In this page you can find the example usage for javax.persistence Query getHints.

Prototype

Map<String, Object> getHints();

Source Link

Document

Get the properties and hints and associated values that are in effect for the query instance.

Usage

From source file:net.sf.gazpachoquest.qbe.NamedQueryUtil.java

/**
 * 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.
 *///from   ww w.  jav a2 s .  com
private String getQueryString(final Query query) {
    Map<String, Object> hints = query.getHints();
    return hints != null ? (String) hints.get("query") : null;
}

From source file:net.sf.gazpachoquest.qbe.NamedQueryUtil.java

private Query recreateQuery(final Query current, final String newSqlString) {
    Query result = entityManager.createQuery(newSqlString);
    Map<String, Object> hints = current.getHints();

    for (Entry<String, Object> entry : hints.entrySet()) {
        String hintName = entry.getKey();
        Object hint = entry.getValue();
        result.setHint(hintName, hint);//from   w  w  w.j  a va2 s  .  c  om
    }
    return result;
}