Search in sources :

Example 26 with IType

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

the class AbstractJPQLQueryHelperTest method test_ParameterType_02.

@Test
public final void test_ParameterType_02() throws Exception {
    // SELECT a.alias FROM Alias AS a WHERE (a.alias IS NULL AND :param1 IS NULL) OR a.alias = :param1
    IQuery namedQuery = namedQuery("Alias", "alias.param1");
    AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
    IType type = helper.getParameterType(":param1");
    assertNotNull("The type of :param1 should have been found", type);
    assertEquals("The wrong type for :param1 was retrieved", getType(namedQuery, String.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 27 with IType

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

the class AbstractJPQLQueryHelperTest method test_ResultType_08.

@Test
public final void test_ResultType_08() throws Exception {
    // SELECT AVG(p.quantity) FROM Product p
    IQuery namedQuery = namedQuery("Product", "product.quantity");
    AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
    IType type = helper.getResultType();
    assertNotNull("The type of AVG(p.quantity) should have been found", type);
    assertEquals("The wrong type for AVG(p.quantity) 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 28 with IType

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

the class AbstractJPQLQueryHelperTest method test_ResultType_04.

@Test
public final void test_ResultType_04() throws Exception {
    // SELECT 2 + 2.2F FROM Employee e
    IQuery namedQuery = namedQuery("Employee", "employee.addition1");
    AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
    IType type = helper.getResultType();
    assertNotNull("The type of 2 + 2.2F should have been found", type);
    assertEquals("The wrong type for 2 + 2.2F was retrieved", getType(namedQuery, Float.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 29 with IType

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

the class AbstractJPQLQueryHelperTest method test_ParameterType_24.

@Test
public final void test_ParameterType_24() throws Exception {
    // SELECT DISTINCT p From Product p where p.shelfLife.soldDate NOT BETWEEN :date1 AND :newdate
    IQuery namedQuery = namedQuery("Product", "product.date");
    AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
    IType type = helper.getParameterType(":newdate");
    assertNotNull("The type of :newdate should have been found", type);
    assertEquals("The wrong type for :newdate 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 30 with IType

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

the class AbstractJPQLQueryHelperTest method test_ResultType_69.

@Test
public final void test_ResultType_69() throws Exception {
    // SELECT SUM(e.salary) FROM Employee e
    IQuery namedQuery = namedQuery("Employee", "employee.sum");
    AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
    IType type = helper.getResultType();
    assertNotNull("The type of SUM(e.salary) should have been found", type);
    assertEquals("The wrong type for SUM(p.quantity) was retrieved", 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) 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