Search in sources :

Example 1 with IQuery

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

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

the class AbstractJPQLQueryHelperTest method test_ResultType_49.

@Test
public final void test_ResultType_49() throws Exception {
    // SELECT NULLIF(e.name, 'JPQL') FROM Employee e
    IQuery namedQuery = namedQuery("Employee", "employee.nullif1");
    AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
    IType type = helper.getResultType();
    assertNotNull("The type of NULLIF(e.name, 'JPQL') should have been found", type);
    assertEquals("The wrong type for NULLIF(e.name, 'JPQL') 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 3 with IQuery

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

the class AbstractJPQLQueryHelperTest method test_ParameterType_09.

@Test
public final void test_ParameterType_09() throws Exception {
    // select o from Dept o where o.dname in (:dname1, :dname2, :dname3)
    IQuery namedQuery = namedQuery("Dept", "dept.dname");
    AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
    IType type = helper.getParameterType(":dname1");
    assertNotNull("The type of :dname1 should have been found", type);
    assertEquals("The wrong type for :newdate 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 4 with IQuery

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

the class AbstractJPQLQueryHelperTest method test_ResultType_61.

@Test
public final void test_ResultType_61() throws Exception {
    // SELECT e.salary / 1000D n From Employee e
    IQuery namedQuery = namedQuery("Employee", "employee.resultVariable3");
    AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
    IType type = helper.getResultType();
    assertNotNull("The type of e.salary / 1000D n as n should have been found", type);
    assertEquals("The wrong type for e.salary / 1000D n as n 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 5 with IQuery

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

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