use of javax.persistence.QueryHint in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReader method buildQueryHints.
private static void buildQueryHints(List<Element> elements, AnnotationDescriptor ann) {
List<QueryHint> queryHints = new ArrayList<QueryHint>(elements.size());
for (Element hint : elements) {
AnnotationDescriptor hintDescriptor = new AnnotationDescriptor(QueryHint.class);
String value = hint.attributeValue("name");
if (value == null) {
throw new AnnotationException("<hint> without name. " + SCHEMA_VALIDATION);
}
hintDescriptor.setValue("name", value);
value = hint.attributeValue("value");
if (value == null) {
throw new AnnotationException("<hint> without value. " + SCHEMA_VALIDATION);
}
hintDescriptor.setValue("value", value);
queryHints.add((QueryHint) AnnotationFactory.create(hintDescriptor));
}
ann.setValue("hints", queryHints.toArray(new QueryHint[queryHints.size()]));
}
use of javax.persistence.QueryHint in project deltaspike by apache.
the class CdiQueryInvocationContext method applyRestrictions.
public Query applyRestrictions(Query query) {
Parameters params = getParams();
Method method = getMethod();
if (params.hasSizeRestriction()) {
query.setMaxResults(params.getSizeRestriciton());
}
if (params.hasFirstResult()) {
query.setFirstResult(params.getFirstResult());
}
if (hasLockMode(method)) {
query.setLockMode(extractLockMode(method));
}
if (hasQueryHints(method)) {
QueryHint[] hints = extractQueryHints(method);
for (QueryHint hint : hints) {
query.setHint(hint.name(), hint.value());
}
}
applyEntityGraph(query, method);
query = applyJpaQueryPostProcessors(query);
return query;
}
Aggregations