Package org.eclipse.persistence.internal.jpa.metadata.accessors.objects

Examples of org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataClass


            // By the time this method is called we should have built a
            // MetadataClass for all the model elements (and then some ... )
            // which are the only classes we really care about. This is acting
            // like a catch all and for any jdk classes just return a
            // MetadataClass with the same class name.
            addMetadataClass(new MetadataClass(this, className));
        }
       
        return getMetadataClasses().get(className);
    }
View Full Code Here


           
            // Tell an embeddable accessor that is a map key to a collection
            // to pre-process itself.
            if (accessor.isMappedKeyMapAccessor()) {
                MappedKeyMapAccessor mapAccessor = (MappedKeyMapAccessor) accessor;
                MetadataClass mapKeyClass = mapAccessor.getMapKeyClass();
               
                // If the map key class is not specified, we need to look it
                // up from the accessor type.
                if (mapKeyClass == null || mapKeyClass.equals(void.class)) {
                    mapKeyClass = accessor.getAccessibleObject().getMapKeyClass(getDescriptor());
                   
                    if (mapKeyClass == null && mapAccessor.getMapKey() == null) {
                        // We don't have a map key class or map key, throw an exception.
                        throw ValidationException.unableToDetermineMapKeyClass(accessor.getAttributeName(), accessor.getJavaClass());
View Full Code Here

            }
           
            for (MappingAccessor mappingAccessor : accessor.getDescriptor().getAccessors()) {
                if (! mappingAccessor.isTransient()) {
                    MetadataAnnotatedElement annotatedElement = mappingAccessor.getAnnotatedElement();
                    MetadataClass rawClass = annotatedElement.getRawClass(mappingAccessor.getDescriptor());

                    // NOTE: order of checking is important.
                    String attributeType;
                    String types = className;
                   
                    if (mappingAccessor.isBasic()) {
                        types = types + ", " + getUnqualifiedType(getBoxedType(annotatedElement), imports);
                        attributeType = AttributeType.SingularAttribute.name();
                        imports.put(attributeType, "javax.persistence.metamodel.SingularAttribute");
                    } else {
                        if (rawClass.isList()) {
                            attributeType = AttributeType.ListAttribute.name();
                            imports.put(attributeType, "javax.persistence.metamodel.ListAttribute");
                        } else if (rawClass.isSet()) {
                            attributeType = AttributeType.SetAttribute.name();
                            imports.put(attributeType, "javax.persistence.metamodel.SetAttribute");
                        } else if (rawClass.isMap()) {
                            attributeType = AttributeType.MapAttribute.name();
                            imports.put(attributeType, "javax.persistence.metamodel.MapAttribute");
                        } else if (rawClass.isCollection()) {
                            attributeType = AttributeType.CollectionAttribute.name();
                            imports.put(attributeType, "javax.persistence.metamodel.CollectionAttribute");
                        } else {
                            attributeType = AttributeType.SingularAttribute.name();
                            imports.put(attributeType, "javax.persistence.metamodel.SingularAttribute");
                        }
                       
                        if (mappingAccessor.isMapAccessor()) {
                            if (mappingAccessor.isMappedKeyMapAccessor()) {
                                MetadataClass mapKeyClass = ((MappedKeyMapAccessor) mappingAccessor).getMapKeyClass();
                                types = types + ", " + getUnqualifiedType(mapKeyClass.getName(), imports) + ", " + getUnqualifiedType(mappingAccessor.getReferenceClassName(), imports);
                            } else {
                                String mapKeyType;
                                if (annotatedElement.isGenericCollectionType()) {
                                    // Grab the map key class from the generic.
                                    mapKeyType = annotatedElement.getGenericType().get(1);
View Full Code Here

        // Add the standard canonical model generator imports.
        imps.add("javax.annotation.Generated");
        imps.add("javax.persistence.metamodel.StaticMetamodel");
       
        // Import the parent canonical class if need be.
        MetadataClass cls = (MetadataClass) accessor.getAnnotatedElement();
        MetadataClass parentCls = cls.getSuperclass();
        MetadataProject project = accessor.getProject();
       
        if (project.hasEntity(parentCls) || project.hasEmbeddable(parentCls) || project.hasMappedSuperclass(parentCls)) {
            String qualifiedParentCanonicalName = persistenceUnit.getQualifiedCanonicalName(parentCls.getName());
            parentCanonicalName = getName(qualifiedParentCanonicalName);
            String parentCanonicalPackage = getPackage(qualifiedParentCanonicalName);
           
            if (! parentCanonicalPackage.equals(childCanonicalpackage)) {
                imps.add(qualifiedParentCanonicalName);
View Full Code Here

     * 2 - New element but exclude unlisted classes - ignore it.
     * 3 - Existing element, but accessor loaded from XML (it's a new accessor then) - don't touch it
     * 4 - Existing element, but accessor loaded from Annotations - add new accessor overridding the old.
     */
    public void addEmbeddableAccessor(Element element) {
        MetadataClass cls = factory.getMetadataClass(element);
       
        if (project.hasEmbeddable(cls)) {
            EmbeddableAccessor embeddableAccessor = project.getEmbeddableAccessor(cls);
           
            // Don't touch it if it was loaded from XML.
            if (! embeddableAccessor.loadedFromXML()) {
                if (excludeUnlistedClasses(cls)) {
                    // remove it!
                } else {
                    // override it!
                    addEmbeddableAccessor(new EmbeddableAccessor(cls.getAnnotation(Embeddable.class), cls, project));
                }
            }
        } else if (! excludeUnlistedClasses(cls)) {
            // add it!
            addEmbeddableAccessor(new EmbeddableAccessor(cls.getAnnotation(Embeddable.class), cls, project));
        }
    }
View Full Code Here

     * 2 - New element but exclude unlisted classes - ignore it.
     * 3 - Existing element, loaded from XML - don't touch it (it's already a new un-processed accessor)
     * 4 - Existing element, loaded from Annotations - add new accessor overridding the old.
     */
    public void addEntityAccessor(Element element) {
        MetadataClass cls = factory.getMetadataClass(element);
       
        if (project.hasEntity(cls)) {
            EntityAccessor entityAccessor = project.getEntityAccessor(cls);
           
            // Don't touch it if it was loaded from XML.
            if (! entityAccessor.loadedFromXML()) {
                if (excludeUnlistedClasses(cls)) {
                    // remove it!
                } else {
                    // override it!
                    project.addEntityAccessor(new EntityAccessor(cls.getAnnotation(Entity.class), cls, project));
                }
            }
        } else if (! excludeUnlistedClasses(cls)) {
            // add it!
            project.addEntityAccessor(new EntityAccessor(cls.getAnnotation(Entity.class), cls, project));
        }
    }
View Full Code Here

     * 2 - New element but exclude unlisted classes - ignore it.
     * 3 - Existing element, but accessor loaded from XML (it's a new accessor then) - don't touch it
     * 4 - Existing element, but accessor loaded from Annotations - add new accessor overridding the old.
     */
    public void addMappedSuperclassAccessor(Element element) {
        MetadataClass cls = factory.getMetadataClass(element);
       
        if (project.hasMappedSuperclass(cls)) {
            MappedSuperclassAccessor mappedSuperclassAccessor = project.getMappedSuperclass(cls);
           
            // Don't touch it if it was loaded from XML.
            if (! mappedSuperclassAccessor.loadedFromXML()) {
                if (excludeUnlistedClasses(cls)) {
                    // remove it!
                } else {
                    // override it!
                    project.addMappedSuperclass(new MappedSuperclassAccessor(cls.getAnnotation(MappedSuperclass.class), cls, project));
                }
            }
        } else if (! excludeUnlistedClasses(cls)) {
            // add it!
            project.addMappedSuperclass(new MappedSuperclassAccessor(cls.getAnnotation(MappedSuperclass.class), cls, project));
        }
    }
View Full Code Here

     * If the accessor is no longer valid it we should probably look into
     * removing the accessor from the project. For now I don't think its a big
     * deal.
     */
    public boolean containsElement(Element element) {
        MetadataClass cls = factory.getMetadataClass(element);
       
        if (project.hasEntity(cls)) {
            return isValidAccessor(project.getEntityAccessor(cls), element.getAnnotation(javax.persistence.Entity.class));
        }
       
View Full Code Here

     * when processing JPA converters that can default (Enumerated and Temporal)
     * based on the reference class.
     */
    public MetadataClass getMapKeyReferenceClass() {
        if (isMapAccessor()) {
            MetadataClass referenceClass = getAccessibleObject().getMapKeyClass(getDescriptor());
       
            if (referenceClass == null) {
                throw ValidationException.unableToDetermineMapKeyClass(getAttributeName(), getJavaClass());
            }           
       
            /**
             * 266912:  Use of parameterized generic types like Map<X,Y> inherits from class<T> in a MappedSuperclass field
             * will cause referencing issues - as in we are unable to determine the correct type for T.
             * A workaround for this is to detect when we are in this state and return a standard top level class.
             * An invalid class will be of the form MetadataClass.m_name="T"
             */
            if(this.getClassAccessor().isMappedSuperclass()) {
                // Determine whether we are directly referencing a class or using a parameterized generic reference
                // by trying to load the class and catching any validationException.
                // If we do not get an exception on getClass then the referenceClass.m_name is valid and should be directly returned
                try {
                    MetadataHelper.getClassForName(referenceClass.getName(), getMetadataFactory().getLoader());
                } catch (ValidationException exception) {
                    // Default to Void for parameterized types
                    // Ideally we would need a MetadataClass.isParameterized() to inform us instead.
                    return new MetadataClass(this.getMetadataFactory(), Void.class);
                }                         
            }
            return referenceClass;
        } else {
            return getMetadataFactory().getMetadataClass(void.class.getName());
View Full Code Here

     * @see ElementCollectionAccessor
     */
    protected void processContainerPolicyAndIndirection(CollectionMapping mapping, String mapKey) {
        if (isMappedKeyMapAccessor()) {
            MappedKeyMapAccessor mapKeyMapAccessor = (MappedKeyMapAccessor) this;
            MetadataClass mapKeyClass = mapKeyMapAccessor.getMapKeyClass();
            if (mapKeyClass != null && (getProject().hasEntity(mapKeyClass) || getProject().hasEmbeddable(mapKeyClass) || mapKeyMapAccessor.getMapKeyColumn() != null)) {
            // TODO: if map key is specified we should throw an exception.
               processMapKeyClass(mapKeyClass, mapping, mapKeyMapAccessor);
            } else {
                // Set the indirection policy on the mapping
View Full Code Here

TOP

Related Classes of org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataClass

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.