use of org.eclipse.persistence.jpa.jpql.tools.spi.IType in project eclipselink by eclipse-ee4j.
the class EclipseLinkJPQLQueryHelperTest2_4 method test_ResultType_FromSubquery_4.
@Test
public void test_ResultType_FromSubquery_4() throws Exception {
// Select e3.result from Employee e, (Select count(e2) + 2.2 as result, e2.department from Employee e2 group by e2.department) e3 where e.department = e3.department
IQuery namedQuery = namedQuery("Employee", "employee.fromSubquery4");
AbstractJPQLQueryHelper helper = buildQueryHelper(namedQuery);
IType type = helper.getResultType();
assertNotNull("The result type should have been found", type);
assertEquals("The result type was not calculated correctly", getType(namedQuery, Double.class), type);
}
use of org.eclipse.persistence.jpa.jpql.tools.spi.IType in project eclipselink by eclipse-ee4j.
the class AbstractContentAssistVisitor method buildNonCollectionCompoundTypeFilter.
protected Filter<Expression> buildNonCollectionCompoundTypeFilter() {
return new Filter<Expression>() {
@Override
public boolean accept(Expression expression) {
IType type = queryContext.getType(expression);
TypeHelper typeHelper = queryContext.getTypeHelper();
return !typeHelper.isCollectionType(type) && !typeHelper.isMapType(type);
}
};
}
use of org.eclipse.persistence.jpa.jpql.tools.spi.IType in project eclipselink by eclipse-ee4j.
the class AbstractContentAssistVisitor method buildCollectionCompoundTypeFilter.
protected Filter<Expression> buildCollectionCompoundTypeFilter() {
return new Filter<Expression>() {
@Override
public boolean accept(Expression expression) {
IType type = queryContext.getType(expression);
TypeHelper typeHelper = queryContext.getTypeHelper();
return typeHelper.isCollectionType(type) || typeHelper.isMapType(type);
}
};
}
use of org.eclipse.persistence.jpa.jpql.tools.spi.IType in project eclipselink by eclipse-ee4j.
the class CollectionValuedPathExpressionStateObject method resolveManagedType.
@Override
protected IManagedType resolveManagedType() {
IMapping mapping = getMapping();
if (mapping == null) {
return null;
}
TypeHelper typeHelper = getTypeHelper();
ITypeDeclaration typeDeclaration = mapping.getTypeDeclaration();
IType type = typeDeclaration.getType();
// it cannot be traversed
if (typeHelper.isCollectionType(type)) {
return null;
}
// Primitive types cannot have a managed type
if (typeHelper.isPrimitiveType(type)) {
return null;
}
// Retrieve the corresponding managed type for the mapping's type
return getManagedTypeProvider().getManagedType(type);
}
use of org.eclipse.persistence.jpa.jpql.tools.spi.IType in project eclipselink by eclipse-ee4j.
the class CollectionValuedPathExpressionStateObject method resolveType.
@Override
protected IType resolveType() {
TypeHelper typeHelper = getTypeHelper();
ITypeDeclaration typeDeclaration = getTypeDeclaration();
IType type = typeDeclaration.getType();
// For a collection type, return the first type parameter
if (typeHelper.isCollectionType(type)) {
ITypeDeclaration[] typeParameters = typeDeclaration.getTypeParameters();
if (typeParameters.length > 0) {
type = typeParameters[0].getType();
}
} else // For a map type, by default the value is the actual type to return
if (typeHelper.isMapType(type)) {
ITypeDeclaration[] typeParameters = typeDeclaration.getTypeParameters();
if (typeParameters.length == 2) {
type = typeParameters[1].getType();
}
}
// only deals with the primitive wrapper type
return typeHelper.convertPrimitive(type);
}
Aggregations