Search in sources :

Example 26 with IQuery

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

the class AbstractJPQLQueryHelperTest method test_ParameterType_19.

@Test
public final void test_ParameterType_19() throws Exception {
    // UPDATE Employee e SET e.manager = ?1 WHERE e.department = ?2
    IQuery namedQuery = namedQuery("Employee", "employee.update.positional");
    AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
    IType type = helper.getParameterType("?2");
    assertNotNull("The type of ?2 should have been found", type);
    assertEquals("The wrong type for ?2 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 IQuery

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

the class AbstractJPQLQueryHelperTest method test_ResultType_46.

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

Example 28 with IQuery

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

the class AbstractJPQLQueryHelperTest method test_ResultType_42.

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

Example 29 with IQuery

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

the class AbstractJPQLQueryHelperTest method test_ResultType_10.

@Test
public final void test_ResultType_10() throws Exception {
    // SELECT CASE WHEN e.name = 'JPQL' THEN e.working
    // WHEN 1 + 2 THEN TRUE
    // ELSE p.completed
    // END
    // FROM Employee e, Project p
    IQuery namedQuery = namedQuery("Employee", "employee.case2");
    AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
    IType type = helper.getResultType();
    assertNotNull("The type of CASE(...) should have been found", type);
    assertEquals("The wrong type for CASE(...) was retrieved", getType(namedQuery, Boolean.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 30 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)

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