Search in sources :

Example 46 with IType

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

the class AbstractJPQLQueryHelperTest method test_ResultType_24.

@Test
public final void test_ResultType_24() throws Exception {
    // DELETE FROM Employee e WHERE e.department = :dept
    IQuery namedQuery = namedQuery("Employee", "employee.delete.dept");
    AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
    IType type = helper.getResultType();
    assertNotNull("The object type should have been returned", type);
    assertEquals("The wrong type 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) JPQLCoreTest(org.eclipse.persistence.jpa.tests.jpql.JPQLCoreTest)

Example 47 with IType

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

the class AbstractJPQLQueryHelperTest method test_ResultType_65.

@Test
public final void test_ResultType_65() throws Exception {
    // SELECT AVG(e.salary) - 2E2 FROM Employee e
    IQuery namedQuery = namedQuery("Employee", "employee.substraction2");
    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 48 with IType

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

the class AbstractJPQLQueryHelperTest method test_ParameterType_17.

@Test
public final void test_ParameterType_17() throws Exception {
    // SELECT e FROM Employee e WHERE e.salary = (SELECT MAX(e.salary) FROM Employee a WHERE a.department = :dept)
    IQuery namedQuery = namedQuery("Employee", "employee.dept");
    AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
    IType type = helper.getParameterType(":dept");
    assertNotNull("The type of :dept should have been found", type);
    assertEquals("The wrong type for :dept 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 49 with IType

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

the class AbstractJPQLQueryHelperTest method test_ResultType_30.

@Test
public final void test_ResultType_30() throws Exception {
    // SELECT CASE WHEN e.name = 'Pascal' THEN jpql.query.EnumType.FIRST_NAME
    // WHEN e.name = 'JPQL'   THEN jpql.query.EnumType.LAST_NAME
    // ELSE jpql.query.EnumType.NAME
    // END
    // FROM Employee e
    IQuery namedQuery = namedQuery("Employee", "employee.enum");
    AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
    IType type = helper.getResultType();
    assertNotNull("The type of the case should have been found", type);
    assertEquals("The wrong type for 2 - 2.2F was retrieved", helper.getTypeRepository().getType("jpql.query.EnumType"), 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 50 with IType

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

the class AbstractJPQLQueryHelperTest method test_ParameterType_05.

@Test
public final void test_ParameterType_05() throws Exception {
    // select count(c) FROM Customer c JOIN c.aliases a GROUP BY a.alias HAVING a.alias = SUBSTRING(:string1, :int1, :int2)
    IQuery namedQuery = namedQuery("Customer", "customer.substring");
    AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
    IType type = helper.getParameterType(":int1");
    assertNotNull("The type of :int1 should have been found", type);
    assertEquals("The wrong type for :int1 was retrieved", getType(namedQuery, Integer.class), type);
}
Also used : BigInteger(java.math.BigInteger) 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