Search in sources :

Example 1 with MappingParameter

use of com.blazebit.persistence.view.MappingParameter in project blaze-persistence by Blazebit.

the class AnnotationMappingReader method getMapping.

public static Annotation getMapping(String attributeName, AnnotatedElement annotatedElement, boolean implicitMapping) {
    Mapping mapping = annotatedElement.getAnnotation(Mapping.class);
    if (mapping == null) {
        IdMapping idMapping = annotatedElement.getAnnotation(IdMapping.class);
        if (idMapping != null) {
            if (idMapping.value().isEmpty()) {
                idMapping = new IdMappingLiteral(attributeName);
            }
            return idMapping;
        }
        MappingParameter mappingParameter = annotatedElement.getAnnotation(MappingParameter.class);
        if (mappingParameter != null) {
            return mappingParameter;
        }
        MappingSubquery mappingSubquery = annotatedElement.getAnnotation(MappingSubquery.class);
        if (mappingSubquery != null) {
            return mappingSubquery;
        }
        MappingCorrelated mappingCorrelated = annotatedElement.getAnnotation(MappingCorrelated.class);
        if (mappingCorrelated != null) {
            return mappingCorrelated;
        }
        MappingCorrelatedSimple mappingCorrelatedSimple = annotatedElement.getAnnotation(MappingCorrelatedSimple.class);
        if (mappingCorrelatedSimple != null) {
            return mappingCorrelatedSimple;
        }
        if (implicitMapping) {
            mapping = new MappingLiteral(attributeName);
        } else {
            return null;
        }
    }
    if (mapping.value().isEmpty()) {
        mapping = new MappingLiteral(attributeName, mapping);
    }
    return mapping;
}
Also used : MappingCorrelatedSimple(com.blazebit.persistence.view.MappingCorrelatedSimple) MappingParameter(com.blazebit.persistence.view.MappingParameter) MappingCorrelated(com.blazebit.persistence.view.MappingCorrelated) EntityViewInheritanceMapping(com.blazebit.persistence.view.EntityViewInheritanceMapping) EntityViewRootMapping(com.blazebit.persistence.view.spi.EntityViewRootMapping) Mapping(com.blazebit.persistence.view.Mapping) IdMapping(com.blazebit.persistence.view.IdMapping) MappingSubquery(com.blazebit.persistence.view.MappingSubquery) IdMapping(com.blazebit.persistence.view.IdMapping)

Example 2 with MappingParameter

use of com.blazebit.persistence.view.MappingParameter in project blaze-persistence by Blazebit.

the class AnnotationMappingReader method getMapping.

public static Annotation getMapping(AnnotatedElement annotatedElement, Constructor<?> constructor, int index, MetamodelBootContext context) {
    if (annotatedElement.isAnnotationPresent(IdMapping.class)) {
        context.addError("The @IdMapping annotation is disallowed for entity view constructors for the " + ParameterAttributeMapping.getLocation(constructor, index));
        return null;
    }
    Mapping mapping = annotatedElement.getAnnotation(Mapping.class);
    if (mapping != null) {
        return mapping;
    }
    MappingParameter mappingParameter = annotatedElement.getAnnotation(MappingParameter.class);
    if (mappingParameter != null) {
        return mappingParameter;
    }
    MappingSubquery mappingSubquery = annotatedElement.getAnnotation(MappingSubquery.class);
    if (mappingSubquery != null) {
        return mappingSubquery;
    }
    MappingCorrelated mappingCorrelated = annotatedElement.getAnnotation(MappingCorrelated.class);
    if (mappingCorrelated != null) {
        return mappingCorrelated;
    }
    MappingCorrelatedSimple mappingCorrelatedSimple = annotatedElement.getAnnotation(MappingCorrelatedSimple.class);
    if (mappingCorrelatedSimple != null) {
        return mappingCorrelatedSimple;
    }
    Self self = annotatedElement.getAnnotation(Self.class);
    if (self != null) {
        return self;
    }
    context.addError("No entity view mapping annotation given for the " + ParameterAttributeMapping.getLocation(constructor, index));
    return null;
}
Also used : MappingCorrelatedSimple(com.blazebit.persistence.view.MappingCorrelatedSimple) MappingParameter(com.blazebit.persistence.view.MappingParameter) MappingCorrelated(com.blazebit.persistence.view.MappingCorrelated) EntityViewInheritanceMapping(com.blazebit.persistence.view.EntityViewInheritanceMapping) EntityViewRootMapping(com.blazebit.persistence.view.spi.EntityViewRootMapping) Mapping(com.blazebit.persistence.view.Mapping) IdMapping(com.blazebit.persistence.view.IdMapping) MappingSubquery(com.blazebit.persistence.view.MappingSubquery) Self(com.blazebit.persistence.view.Self)

Aggregations

EntityViewInheritanceMapping (com.blazebit.persistence.view.EntityViewInheritanceMapping)2 IdMapping (com.blazebit.persistence.view.IdMapping)2 Mapping (com.blazebit.persistence.view.Mapping)2 MappingCorrelated (com.blazebit.persistence.view.MappingCorrelated)2 MappingCorrelatedSimple (com.blazebit.persistence.view.MappingCorrelatedSimple)2 MappingParameter (com.blazebit.persistence.view.MappingParameter)2 MappingSubquery (com.blazebit.persistence.view.MappingSubquery)2 EntityViewRootMapping (com.blazebit.persistence.view.spi.EntityViewRootMapping)2 Self (com.blazebit.persistence.view.Self)1