use of org.eclipse.persistence.jpa.jpql.tools.spi.IQuery in project eclipselink by eclipse-ee4j.
the class AbstractJPQLQueryHelperTest method test_ParameterType_07.
@Test
public final void test_ParameterType_07() throws Exception {
// select c.firstName FROM Customer c Group By c.firstName HAVING c.firstName = concat(:fname, :lname)
IQuery namedQuery = namedQuery("Customer", "customer.name");
AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
IType type = helper.getParameterType(":lname");
assertNotNull("The type of :lname should have been found", type);
assertEquals("The wrong type for :lname was retrieved", getType(namedQuery, String.class), type);
}
use of org.eclipse.persistence.jpa.jpql.tools.spi.IQuery in project eclipselink by eclipse-ee4j.
the class AbstractJPQLQueryHelperTest method test_ResultType_26.
@Test
public final void test_ResultType_26() throws Exception {
// SELECT AVG(e.salary) / 2E2 FROM Employee e
IQuery namedQuery = namedQuery("Employee", "employee.division2");
AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
IType type = helper.getResultType();
assertNotNull("The type of AVG(salary) / 2E2 should have been found", type);
assertEquals("The wrong type for AVG(salary) / 2E2 was retrieved", getType(namedQuery, Double.class), type);
}
use of org.eclipse.persistence.jpa.jpql.tools.spi.IQuery in project eclipselink by eclipse-ee4j.
the class AbstractJPQLQueryHelperTest method test_ResultType_61.
@Test
public final void test_ResultType_61() throws Exception {
// SELECT e.salary / 1000D n From Employee e
IQuery namedQuery = namedQuery("Employee", "employee.resultVariable3");
AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
IType type = helper.getResultType();
assertNotNull("The type of e.salary / 1000D n as n should have been found", type);
assertEquals("The wrong type for e.salary / 1000D n as n was retrieved", getType(namedQuery, Double.class), type);
}
use of org.eclipse.persistence.jpa.jpql.tools.spi.IQuery in project eclipselink by eclipse-ee4j.
the class JavaEntity method buildQueries.
protected Map<String, IQuery> buildQueries() {
Map<String, IQuery> queries = new HashMap<>();
try {
Class<?> type = getType().getType();
Annotation[] annotations = type.getAnnotations();
NamedQueries namedQueries = getAnnotation(annotations, NamedQueries.class);
if (namedQueries != null) {
for (NamedQuery namedQuery : namedQueries.value()) {
IQuery query = buildQuery(namedQuery);
queries.put(namedQuery.name(), query);
}
} else {
NamedQuery namedQuery = getAnnotation(annotations, NamedQuery.class);
if (namedQuery != null) {
IQuery query = buildQuery(namedQuery);
queries.put(namedQuery.name(), query);
}
}
} catch (Exception e) {
// Ignore
}
return queries;
}
use of org.eclipse.persistence.jpa.jpql.tools.spi.IQuery in project eclipselink by eclipse-ee4j.
the class DefaultJPQLQueryHelperTest2_1 method namedQuery.
@Override
protected IQuery namedQuery(String entityName, String queryName) throws Exception {
IEntity entity = entity(entityName);
IQuery namedQuery = entity.getNamedQuery(queryName);
assertNotNull("The named query " + queryName + " could not be found on " + entityName, namedQuery);
return namedQuery;
}
Aggregations