Search in sources :

Example 91 with IType

use of org.eclipse.persistence.jpa.jpql.tools.spi.IType in project eclipselink by eclipse-ee4j.

the class AbstractJPQLQueryHelperTest method test_ResultType_12.

@Test
public final void test_ResultType_12() throws Exception {
    // SELECT e FROM Employee E
    IQuery namedQuery = namedQuery("Employee", "employee.caseInsensitive");
    AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
    IType type = helper.getResultType();
    assertNotNull("The type of e should have been found", type);
    assertEquals("The wrong type for e was retrieved", mappedType(namedQuery, "Employee"), 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) JPQLCoreTest(org.eclipse.persistence.jpa.tests.jpql.JPQLCoreTest)

Example 92 with IType

use of org.eclipse.persistence.jpa.jpql.tools.spi.IType in project eclipselink by eclipse-ee4j.

the class AbstractJPQLQueryHelperTest method test_ResultType_45.

@Test
public final void test_ResultType_45() throws Exception {
    // SELECT AVG(e.salary) * 2E2 FROM Employee e
    IQuery namedQuery = namedQuery("Employee", "employee.multiplication2");
    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);
}
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) JPQLCoreTest(org.eclipse.persistence.jpa.tests.jpql.JPQLCoreTest)

Example 93 with IType

use of org.eclipse.persistence.jpa.jpql.tools.spi.IType in project eclipselink by eclipse-ee4j.

the class AbstractJPQLQueryHelperTest method test_ResultType_23.

@Test
public final void test_ResultType_23() throws Exception {
    // SELECT {d '2008-12-31'} FROM Employee e
    IQuery namedQuery = namedQuery("Employee", "employee.date2");
    AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
    IType type = helper.getResultType();
    assertNotNull("The type of {d '2008-12-31'} should have been found", type);
    assertEquals("The wrong type for {d '2008-12-31'} was retrieved", getType(namedQuery, java.sql.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) JPQLCoreTest(org.eclipse.persistence.jpa.tests.jpql.JPQLCoreTest)

Example 94 with IType

use of org.eclipse.persistence.jpa.jpql.tools.spi.IType in project eclipselink by eclipse-ee4j.

the class AbstractJPQLQueryHelperTest method test_ResultType_76.

@Test
public final void test_ResultType_76() throws Exception {
    // SELECT VALUE(v) FROM Alias a JOIN a.ids v
    IQuery namedQuery = namedQuery("Alias", "alias.value1");
    AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
    IType type = helper.getResultType();
    assertNotNull("The type of VALUE(v) should have been found", type);
    assertEquals("The wrong type for VALUE(v) 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) JPQLCoreTest(org.eclipse.persistence.jpa.tests.jpql.JPQLCoreTest)

Example 95 with IType

use of org.eclipse.persistence.jpa.jpql.tools.spi.IType in project eclipselink by eclipse-ee4j.

the class AbstractJPQLQueryHelperTest method test_ResultType_05.

@Test
public final void test_ResultType_05() throws Exception {
    // SELECT AVG(e.salary) + 2E2 FROM Employee e
    IQuery namedQuery = namedQuery("Employee", "employee.addition2");
    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);
}
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) JPQLCoreTest(org.eclipse.persistence.jpa.tests.jpql.JPQLCoreTest)

Aggregations

IType (org.eclipse.persistence.jpa.jpql.tools.spi.IType)137 Test (org.junit.Test)113 AbstractJPQLQueryHelper (org.eclipse.persistence.jpa.jpql.tools.AbstractJPQLQueryHelper)112 IQuery (org.eclipse.persistence.jpa.jpql.tools.spi.IQuery)112 JPQLCoreTest (org.eclipse.persistence.jpa.tests.jpql.JPQLCoreTest)103 BigInteger (java.math.BigInteger)16 TypeHelper (org.eclipse.persistence.jpa.jpql.tools.TypeHelper)8 ITypeDeclaration (org.eclipse.persistence.jpa.jpql.tools.spi.ITypeDeclaration)7 Date (java.util.Date)6 ArrayList (java.util.ArrayList)3 AbsExpression (org.eclipse.persistence.jpa.jpql.parser.AbsExpression)2 AbstractDoubleEncapsulatedExpression (org.eclipse.persistence.jpa.jpql.parser.AbstractDoubleEncapsulatedExpression)2 AbstractExpression (org.eclipse.persistence.jpa.jpql.parser.AbstractExpression)2 AbstractPathExpression (org.eclipse.persistence.jpa.jpql.parser.AbstractPathExpression)2 AbstractSingleEncapsulatedExpression (org.eclipse.persistence.jpa.jpql.parser.AbstractSingleEncapsulatedExpression)2 AbstractTripleEncapsulatedExpression (org.eclipse.persistence.jpa.jpql.parser.AbstractTripleEncapsulatedExpression)2 AdditionExpression (org.eclipse.persistence.jpa.jpql.parser.AdditionExpression)2 AllOrAnyExpression (org.eclipse.persistence.jpa.jpql.parser.AllOrAnyExpression)2 AndExpression (org.eclipse.persistence.jpa.jpql.parser.AndExpression)2 ArithmeticExpression (org.eclipse.persistence.jpa.jpql.parser.ArithmeticExpression)2