use of org.eclipse.persistence.jpa.jpql.tools.spi.IQuery in project eclipselink by eclipse-ee4j.
the class DefaultJPQLQueryHelperTest2_1 method test_ResultType_Treat_1.
@Test
public void test_ResultType_Treat_1() throws Exception {
// SELECT TREAT(TREAT(p.project LargeProject).parent AS LargeProject).endDate
// FROM Product p
IQuery namedQuery = namedQuery("Product", "product.treat");
AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
IType type = helper.getResultType();
assertNotNull("The type of TREAT(TREAT(p.project LargeProject).parent AS LargeProject).endDate should have been found", type);
assertEquals("The wrong type for TREAT(TREAT(p.project LargeProject).parent AS LargeProject).endDate was retrieved", getType(namedQuery, Date.class), type);
}
use of org.eclipse.persistence.jpa.jpql.tools.spi.IQuery in project eclipselink by eclipse-ee4j.
the class EclipseLinkJPQLQueryHelperTest method test_ResultType_Func_4.
@Test
public void test_ResultType_Func_4() throws Exception {
// SELECT FUNC('age', e.empId, ?name) FROM Employee e
IQuery namedQuery = namedQuery("Employee", "employee.func4");
AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
IType type = helper.getResultType();
assertNotNull("The type of FUNC('age', e.empId, ?name) should have been found", type);
assertEquals("The wrong type for FUNC('age', e.empId, ?name) was retrieved", getType(namedQuery, Object.class), type);
}
use of org.eclipse.persistence.jpa.jpql.tools.spi.IQuery in project eclipselink by eclipse-ee4j.
the class EclipseLinkJPQLQueryHelperTest2_4 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;
}
use of org.eclipse.persistence.jpa.jpql.tools.spi.IQuery in project eclipselink by eclipse-ee4j.
the class EclipseLinkJPQLQueryHelperTest2_4 method test_ResultType_FromSubquery_2.
@Test
public void test_ResultType_FromSubquery_2() throws Exception {
// Select e3.count from Employee e, (Select count(e2) as count, e2.department from Employee e2 group by e2.department) e3 where e.department = e3.department
IQuery namedQuery = namedQuery("Employee", "employee.fromSubquery3");
AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
IType type = helper.getResultType();
assertNotNull("The result type should have been found", type);
assertEquals("The result type was not calculated correctly", getType(namedQuery, Long.class), type);
}
use of org.eclipse.persistence.jpa.jpql.tools.spi.IQuery in project eclipselink by eclipse-ee4j.
the class EclipseLinkJPQLQueryHelperTest2_4 method test_ResultType_FromSubquery_1.
@Test
public void test_ResultType_FromSubquery_1() throws Exception {
// Select e3.salary from Employee e, (Select count(e2), e2.department from Employee e2 group by e2.department) e3 where e.department = e3.department
IQuery namedQuery = namedQuery("Employee", "employee.fromSubquery2");
AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
IType type = helper.getResultType();
assertNotNull("The result type should have been found", type);
assertEquals("The result type was not calculated correctly", getType(namedQuery, Object.class), type);
}
Aggregations