Search in sources :

Example 76 with IQuery

use of org.eclipse.persistence.jpa.jpql.tools.spi.IQuery 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 77 with IQuery

use of org.eclipse.persistence.jpa.jpql.tools.spi.IQuery 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 78 with IQuery

use of org.eclipse.persistence.jpa.jpql.tools.spi.IQuery 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)

Example 79 with IQuery

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

the class AbstractJPQLQueryHelperTest method test_ResultType_13.

@Test
public final void test_ResultType_13() throws Exception {
    // SELECT COALESCE(o.price, o.price) FROM Order o
    IQuery namedQuery = namedQuery("Order", "order.coalesce1");
    AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
    IType type = helper.getResultType();
    assertNotNull("The type of COALESCE(o.price, o.price) should have been found", type);
    assertEquals("The wrong type for COALESCE(o.price, o.price) was retrieved", getType(namedQuery, BigInteger.class), type);
}
Also used : IQuery(org.eclipse.persistence.jpa.jpql.tools.spi.IQuery) AbstractJPQLQueryHelper(org.eclipse.persistence.jpa.jpql.tools.AbstractJPQLQueryHelper) BigInteger(java.math.BigInteger) IType(org.eclipse.persistence.jpa.jpql.tools.spi.IType) Test(org.junit.Test) JPQLCoreTest(org.eclipse.persistence.jpa.tests.jpql.JPQLCoreTest)

Example 80 with IQuery

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

the class AbstractJPQLQueryHelperTest method test_ParameterType_22.

@Test
public final void test_ParameterType_22() 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(":date1");
    assertNotNull("The type of :date1 should have been found", type);
    assertEquals("The wrong type for :date1 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)

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