Search in sources :

Example 56 with IQuery

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);
}
Also used : IQuery(org.eclipse.persistence.jpa.jpql.tools.spi.IQuery) AbstractJPQLQueryHelper(org.eclipse.persistence.jpa.jpql.tools.AbstractJPQLQueryHelper) Date(java.util.Date) IType(org.eclipse.persistence.jpa.jpql.tools.spi.IType) Test(org.junit.Test)

Example 57 with IQuery

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);
}
Also used : IQuery(org.eclipse.persistence.jpa.jpql.tools.spi.IQuery) AbstractJPQLQueryHelper(org.eclipse.persistence.jpa.jpql.tools.AbstractJPQLQueryHelper) IType(org.eclipse.persistence.jpa.jpql.tools.spi.IType) Test(org.junit.Test)

Example 58 with IQuery

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;
}
Also used : IQuery(org.eclipse.persistence.jpa.jpql.tools.spi.IQuery) IEntity(org.eclipse.persistence.jpa.jpql.tools.spi.IEntity)

Example 59 with IQuery

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);
}
Also used : IQuery(org.eclipse.persistence.jpa.jpql.tools.spi.IQuery) AbstractJPQLQueryHelper(org.eclipse.persistence.jpa.jpql.tools.AbstractJPQLQueryHelper) IType(org.eclipse.persistence.jpa.jpql.tools.spi.IType) Test(org.junit.Test)

Example 60 with IQuery

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);
}
Also used : IQuery(org.eclipse.persistence.jpa.jpql.tools.spi.IQuery) AbstractJPQLQueryHelper(org.eclipse.persistence.jpa.jpql.tools.AbstractJPQLQueryHelper) IType(org.eclipse.persistence.jpa.jpql.tools.spi.IType) Test(org.junit.Test)

Aggregations

IQuery (org.eclipse.persistence.jpa.jpql.tools.spi.IQuery)120 AbstractJPQLQueryHelper (org.eclipse.persistence.jpa.jpql.tools.AbstractJPQLQueryHelper)112 IType (org.eclipse.persistence.jpa.jpql.tools.spi.IType)112 Test (org.junit.Test)112 JPQLCoreTest (org.eclipse.persistence.jpa.tests.jpql.JPQLCoreTest)103 BigInteger (java.math.BigInteger)16 Date (java.util.Date)7 IEntity (org.eclipse.persistence.jpa.jpql.tools.spi.IEntity)6 NamedQueries (jakarta.persistence.NamedQueries)1 NamedQuery (jakarta.persistence.NamedQuery)1 Annotation (java.lang.annotation.Annotation)1 BigDecimal (java.math.BigDecimal)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Vector (java.util.Vector)1 JavaQuery (org.eclipse.persistence.jpa.tests.jpql.tools.spi.java.JavaQuery)1