return context.executeQuery(jpaQuery);
}
private javax.persistence.Query createJpaQuery(Query query, CdiQueryInvocationContext context) {
EntityManager entityManager = context.getEntityManager();
Parameters params = context.getParams();
javax.persistence.Query result = null;
if (isNotEmpty(query.named())) {
if (!context.hasQueryStringPostProcessors()) {
result = params.applyTo(entityManager.createNamedQuery(query.named()));
} else {
javax.persistence.Query namedQuery = entityManager.createNamedQuery(query.named());
String named = factory.select(namedQuery).extractFrom(namedQuery);
String jpqlQuery = context.applyQueryStringPostProcessors(named);
result = params.applyTo(entityManager.createQuery(jpqlQuery));
}
} else if (isNotEmpty(query.sql())) {
String jpqlQuery = context.applyQueryStringPostProcessors(query.sql());
result = params.applyTo(entityManager.createNativeQuery(jpqlQuery));
} else {
String jpqlQuery = context.applyQueryStringPostProcessors(query.value());
context.setQueryString(jpqlQuery);
result = params.applyTo(entityManager.createQuery(jpqlQuery));
}
return applyRestrictions(context, result);
}