use of org.eclipse.persistence.jpa.jpql.tools.spi.IType in project eclipselink by eclipse-ee4j.
the class NumericTypeComparator method compare.
@Override
public int compare(IType type1, IType type2) {
// Same type
if (type1.equals(type2)) {
return 0;
}
// Object type
IType type = typeHelper.objectType();
if (type1.equals(type))
return -1;
if (type2.equals(type))
return 1;
// Double
type = typeHelper.doubleType();
if (type1.equals(type))
return -1;
if (type2.equals(type))
return 1;
// Float
type = typeHelper.floatType();
if (type1.equals(type))
return -1;
if (type2.equals(type))
return 1;
// BigDecimal
type = typeHelper.bigDecimal();
if (type1.equals(type))
return -1;
if (type2.equals(type))
return 1;
// BigInteger
type = typeHelper.bigInteger();
if (type1.equals(type))
return -1;
if (type2.equals(type))
return 1;
// Long
type = typeHelper.longType();
if (type1.equals(type))
return -1;
if (type2.equals(type))
return 1;
// Integer
type = typeHelper.integerType();
if (type1.equals(type))
return -1;
if (type2.equals(type))
return 1;
return 1;
}
use of org.eclipse.persistence.jpa.jpql.tools.spi.IType in project eclipselink by eclipse-ee4j.
the class EclipseLinkJPQLQueryHelperTest method test_ResultType_Func_3.
@Test
public void test_ResultType_Func_3() throws Exception {
// SELECT FUNC('age', e.empId, e.name) FROM Employee e
IQuery namedQuery = namedQuery("Employee", "employee.func3");
AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
IType type = helper.getResultType();
assertNotNull("The type of FUNC('toString', e.name) should have been found", type);
assertEquals("The wrong type for FUNC('toString', e.name) was retrieved", getType(namedQuery, Object.class), type);
}
use of org.eclipse.persistence.jpa.jpql.tools.spi.IType in project eclipselink by eclipse-ee4j.
the class EclipseLinkJPQLQueryHelperTest method test_ResultType_Func_1.
@Test
public void test_ResultType_Func_1() throws Exception {
// SELECT FUNC('toString', e.name) FROM Employee e
IQuery namedQuery = namedQuery("Employee", "employee.func1");
AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
IType type = helper.getResultType();
assertNotNull("The type of FUNC('toString', e.name) should have been found", type);
assertEquals("The wrong type for FUNC('toString', e.name) was retrieved", getType(namedQuery, Object.class), type);
}
use of org.eclipse.persistence.jpa.jpql.tools.spi.IType in project eclipselink by eclipse-ee4j.
the class EclipseLinkJPQLQueryHelperTest method test_ResultType_Func_2.
@Test
public void test_ResultType_Func_2() throws Exception {
// SELECT FUNC('age', e.empId, e.salary) FROM Employee e
IQuery namedQuery = namedQuery("Employee", "employee.func2");
AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
IType type = helper.getResultType();
assertNotNull("The type of FUNC('age', e.empId, e.salary) should have been found", type);
assertEquals("The wrong type for FUNC('age', e.empId, e.salary) was retrieved", getType(namedQuery, Object.class), type);
}
use of org.eclipse.persistence.jpa.jpql.tools.spi.IType in project eclipselink by eclipse-ee4j.
the class EclipseLinkJPQLQueryHelperTest2_4 method test_ParameterType_FromSubquery_1.
@Test
public void test_ParameterType_FromSubquery_1() throws Exception {
// Select e3.salary from Employee e, (Select count(e2), e2.department from Employee e2 group by e2.department) e3 where e3.department = :dept
IQuery namedQuery = namedQuery("Employee", "employee.fromSubquery1");
AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
IType type = helper.getParameterType(":dept");
assertNotNull("The type of :dept should have been found", type);
assertEquals("The type for :dept was incorrectly calculated", getType(namedQuery, String.class), type);
}
Aggregations