use of org.eclipse.persistence.jpa.jpql.tools.TypeHelper 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.TypeHelper 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);
}
use of org.eclipse.persistence.jpa.jpql.tools.TypeHelper in project eclipselink by eclipse-ee4j.
the class SumFunctionResolver method buildType.
@Override
protected IType buildType() {
IType type = getTypeDeclaration().getType();
TypeHelper helper = getTypeHelper();
// Integral types: int/Integer, long/Long => the result is a Long
if (helper.isIntegralType(type)) {
return helper.longType();
}
// Floating types: float/Float, double/Double => the result is a Double
if (helper.isFloatingType(type)) {
return helper.doubleType();
}
// BigInteger, the result is the same
IType bigIntegerType = helper.bigInteger();
if (type.equals(bigIntegerType)) {
return bigIntegerType;
}
// BigDecimal, the result is the same
IType bigDecimalType = helper.bigDecimal();
if (type.equals(bigDecimalType)) {
return bigDecimalType;
}
// Anything else is an invalid type
return helper.objectType();
}
use of org.eclipse.persistence.jpa.jpql.tools.TypeHelper in project eclipselink by eclipse-ee4j.
the class CollectionEquivalentResolver method buildType.
@Override
protected IType buildType() {
TypeHelper helper = getTypeHelper();
IType unknownType = helper.unknownType();
IType type = null;
for (int index = 0, count = resolvers.size(); index < count; index++) {
IType anotherType = resolvers.get(index).getType();
if (anotherType == unknownType) {
continue;
}
if (type == null) {
type = anotherType;
} else // Two types are not the same, then the type is Object
if (!type.equals(anotherType)) {
return helper.objectType();
}
}
if (type == null) {
type = unknownType;
}
return type;
}
use of org.eclipse.persistence.jpa.jpql.tools.TypeHelper in project eclipselink by eclipse-ee4j.
the class AbstractMapping method calculateMappingType.
/**
* Calculates the type of the mapping represented by this external form.
*
* @param annotations The {@link Annotation Annotations} that are present on the member
* @return The mapping type, which is one of the constants defined in
* {@link org.eclipse.persistence.jpa.jpql.tools.spi.IMappingType IMappingType} when the provider is generic JPA
*/
protected int calculateMappingType(Annotation[] annotations) {
if (hasAnnotation(annotations, ElementCollection.class)) {
return ELEMENT_COLLECTION;
}
if (hasAnnotation(annotations, Embedded.class)) {
return EMBEDDED;
}
if (hasAnnotation(annotations, EmbeddedId.class)) {
return EMBEDDED_ID;
}
if (hasAnnotation(annotations, Id.class)) {
return ID;
}
if (hasAnnotation(annotations, ManyToMany.class)) {
return MANY_TO_MANY;
}
if (hasAnnotation(annotations, ManyToOne.class)) {
return MANY_TO_ONE;
}
if (hasAnnotation(annotations, OneToMany.class)) {
return ONE_TO_MANY;
}
if (hasAnnotation(annotations, OneToOne.class)) {
return ONE_TO_ONE;
}
if (hasAnnotation(annotations, Transient.class)) {
return TRANSIENT;
}
if (hasAnnotation(annotations, Version.class)) {
return VERSION;
}
// Default
IType type = getType();
TypeHelper typeHelper = getTypeRepository().getTypeHelper();
// M:M
if (typeHelper.isCollectionType(type) || typeHelper.isMapType(type)) {
return ONE_TO_MANY;
}
// 1:1
if (parent.getProvider().getEntity(type) != null) {
return ONE_TO_ONE;
}
// Embedded
if (parent.getProvider().getEmbeddable(type) != null) {
return EMBEDDED;
}
// Basic
return BASIC;
}
Aggregations