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

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


                iterator = unlistedClasses.iterator();
                unlisted = true;
            }
            if (iterator.hasNext()) {
                String className = iterator.next();
                MetadataClass candidateClass = m_factory.getMetadataClass(className, unlisted);
                // JBoss Bug 227630: Do not process a null class whether it was from a
                // NPE or a CNF, a warning or exception is thrown in loadClass()
                if (candidateClass != null) {
                    if (PersistenceUnitProcessor.isEntity(candidateClass) && ! m_project.hasEntity(candidateClass) && ! m_project.hasEmbeddable(candidateClass)) {
                        m_project.addEntityAccessor(new EntityAccessor(PersistenceUnitProcessor.getEntityAnnotation(candidateClass), candidateClass, m_project));
View Full Code Here


            // Initialize the class with the package from entity mappings.
            Class entityClass = getClassForName(entity.getClassName());
           
            // Initialize the entity with its metadata descriptor and
            // project.
            entity.initXMLAccessor(new MetadataClass(entityClass, this), new MetadataDescriptor(entityClass, entity), m_project);
           
            if (allEntities.containsKey(entityClass.getName())) {
                // Merge this entity with the existing one.
                allEntities.get(entityClass.getName()).merge(entity);
            } else {
                // Add this entity to the map.
                allEntities.put(entityClass.getName(), entity);
            }
        }
       
        // Process the embeddables.
        for (EmbeddableAccessor embeddable : getEmbeddables()) {
            // Initialize the class with the package from entity mappings.
            Class embeddableClass = getClassForName(embeddable.getClassName());
           
            // Initialize the embeddable with its metadata descriptor and
            // project.
            embeddable.initXMLAccessor(new MetadataClass(embeddableClass, this), new MetadataDescriptor(embeddableClass, embeddable), m_project);
           
            if (allEmbeddables.containsKey(embeddableClass.getName())) {
                // Merge this embeddable with the existing one.
                allEmbeddables.get(embeddableClass.getName()).merge(embeddable);
            } else {   
                // Add this embeddable to the map.
                allEmbeddables.put(embeddableClass.getName(), embeddable);
            }
        }
       
        // Process the mapped superclasses
        for (MappedSuperclassAccessor mappedSuperclass : getMappedSuperclasses()) {
            // Initialize the class with the package from entity mappings.
            Class mappedSuperclassClass = getClassForName(mappedSuperclass.getClassName());
           
            // Just set the accessible object on the mapped superclass for now.
            // Mapped superclasses are reloaded for each entity that inherits
            // from it. After each reload, the initXMLObjects is called and
            // ready to be processed there after.
            mappedSuperclass.setAccessibleObject(new MetadataClass(mappedSuperclassClass, this));
           
            // Add it to the project. This will merge it if necessary.
            m_project.addMappedSuperclass(mappedSuperclassClass.getName(), mappedSuperclass);
        }
    }
View Full Code Here

            file.delete();
           
            // Initialize the newly loaded/built mapped superclass
            MappedSuperclassAccessor mappedSuperclass = entityMappings.getMappedSuperclasses().get(0);
            Class mappedSuperclassClass = getClassForName(mappedSuperclass.getClassName());
            mappedSuperclass.initXMLAccessor(new MetadataClass(mappedSuperclassClass, this), descriptor, m_project);
           
            return mappedSuperclass;
        } catch (Exception e) {
            throw new RuntimeException(e);
            // TODO: Throw an EclipseLink exception.
View Full Code Here

            // for this persistence unit. Its inclusion therefore in this
            // persistence unit is through the use of an Embedded annotation
            // or an embedded element within a known entity. Therefore validate
            // that the reference class does indeed have an Embeddable
            // annotation.
            MetadataClass metadataClass = new MetadataClass(getReferenceClass());
            if (metadataClass.isAnnotationNotPresent(Embeddable.class)) {   
                throw ValidationException.invalidEmbeddedAttribute(getJavaClass(), getAttributeName(), getReferenceClass());
            } else {
                accessor = new EmbeddableAccessor(metadataClass.getAnnotation(Embeddable.class), getReferenceClass(), getProject());
                getProject().addEmbeddableAccessor(accessor);
            }
        }
       
        // Need to set the owning descriptor on the embeddable class before we
View Full Code Here

            } else {
                // Validate our pk contains their pk.
                getOwningDescriptor().validateDerivedPKClassId(getAttributeName(), referencePKClassName, getReferenceClassName());
            }
        } else {
            MetadataClass type = null;
            if (referenceDescriptor.getClassAccessor().hasDerivedId()){
                // Referenced object has a derived ID but no PK class defined,
                // so it must be a simple pk type. Recurse through to get the
                // simple type
                type = ((ObjectAccessor) referenceDescriptor.getMappingAccessor(referenceDescriptor.getIdAttributeName())).getSimplePKType();
            } else {
                // Validate on their basic mapping.
                type = referenceDescriptor.getMappingAccessor(referenceDescriptor.getIdAttributeName()).getRawClass();
            }
           
            getOwningDescriptor().validateDerivedPKClassId(getAttributeName(), getBoxedType(type.getName()), getReferenceClassName());
        }

        // Store the Id attribute name. Used with validation and OrderBy.
        getOwningDescriptor().addIdAttributeName(getAttributeName());
View Full Code Here

     * JPA converters that can default (Enumerated and Temporal) based on the
     * reference class.
     */
    @Override
    public MetadataClass getReferenceClass() {
        MetadataClass cls = getReferenceClassFromGeneric();
        return (cls == null) ? getMetadataClass(void.class) : cls;
    }
View Full Code Here

     * 2 - New element but exclude unlisted classes - ignore it.
     * 3 - Existing element, but accessor loaded from XML - don't touch it
     * 4 - Existing element, but accessor loaded from Annotations - add new accessor overriding the old.
     */
    public void addEmbeddableAccessor(Element element) {
        MetadataClass metadataClass = factory.getMetadataClass(element);
       
        // Remove the accessor from other maps if the type changed.
        removeEntityAccessor(metadataClass);
        removeMappedSuperclassAccessor(metadataClass);
       
        if (project.hasEmbeddable(metadataClass)) {
            EmbeddableAccessor embeddableAccessor = project.getEmbeddableAccessor(metadataClass);
           
            // If it was loaded from XML, reset the pre-processed flag.
            if (embeddableAccessor.loadedFromXML()) {
                embeddableAccessor.clearPreProcessed();
            } else {
                // Was not loaded from XML and existed in the project.
                if (excludeUnlistedClasses(metadataClass)) {
                    // Exclude unlisted classes is now false, remove it!
                    removeEmbeddableAccessor(metadataClass);
                } else {
                    // Otherwise, override the existing accessor!
                    addEmbeddableAccessor(new EmbeddableAccessor(metadataClass.getAnnotation(Embeddable.class), metadataClass, project));
                }
            }
        } else if (! excludeUnlistedClasses(metadataClass)) {
            // add it!
            addEmbeddableAccessor(new EmbeddableAccessor(metadataClass.getAnnotation(Embeddable.class), metadataClass, project));
        }
    }
View Full Code Here

     * 2 - New element but exclude unlisted classes - ignore it.
     * 3 - Existing element, loaded from XML - don't touch it
     * 4 - Existing element, loaded from Annotations - add new accessor overriding the old.
     */
    public void addEntityAccessor(Element element) {
        MetadataClass metadataClass = factory.getMetadataClass(element);
       
        // Remove the accessor from other maps if the type changed.
        removeEmbeddableAccessor(metadataClass);
        removeMappedSuperclassAccessor(metadataClass);
       
        if (project.hasEntity(metadataClass)) {
            EntityAccessor entityAccessor = project.getEntityAccessor(metadataClass);
           
            // If it was loaded from XML, reset the pre-processed flag.
            if (entityAccessor.loadedFromXML()) {
                entityAccessor.clearPreProcessed();
            } else {
                // Was not loaded from XML and existed in the project.
                if (excludeUnlistedClasses(metadataClass)) {
                    // Exclude unlisted classes is now false, remove it!
                    removeEntityAccessor(metadataClass);
                } else {
                    // Otherwise, override the existing accessor!
                    project.addEntityAccessor(new EntityAccessor(metadataClass.getAnnotation(Entity.class), metadataClass, project));
                }
            }
        } else if (! excludeUnlistedClasses(metadataClass)) {
            // add it!
            project.addEntityAccessor(new EntityAccessor(metadataClass.getAnnotation(Entity.class), metadataClass, project));
        }
    }
View Full Code Here

     * 2 - New element but exclude unlisted classes - ignore it.
     * 3 - Existing element, but accessor loaded from XML - don't touch it
     * 4 - Existing element, but accessor loaded from Annotations - add new accessor overridding the old.
     */
    public void addMappedSuperclassAccessor(Element element) {
        MetadataClass metadataClass = factory.getMetadataClass(element);
       
        // Remove the accessor from other maps if the type changed.
        removeEntityAccessor(metadataClass);
        removeEmbeddableAccessor(metadataClass);
       
        if (project.hasMappedSuperclass(metadataClass)) {
            MappedSuperclassAccessor mappedSuperclassAccessor = project.getMappedSuperclassAccessor(metadataClass);
           
            // If it was loaded from XML, reset the pre-processed flag.
            if (mappedSuperclassAccessor.loadedFromXML()) {
                mappedSuperclassAccessor.clearPreProcessed();
            } else {
                // Was not loaded from XML and existed in the project.
                if (excludeUnlistedClasses(metadataClass)) {
                    // Exclude unlisted classes is now false, remove it!
                    project.removeMappedSuperclassAccessor(metadataClass);
                } else {
                    // Otherwise, override the existing accessor!
                    project.addMappedSuperclass(new MappedSuperclassAccessor(metadataClass.getAnnotation(MappedSuperclass.class), metadataClass, project));
                }
            }
        } else if (! excludeUnlistedClasses(metadataClass)) {
            // add it!
            project.addMappedSuperclass(new MappedSuperclassAccessor(metadataClass.getAnnotation(MappedSuperclass.class), metadataClass, project));
        }
    }
View Full Code Here

     * either an Entity, Embeddable or MappedSuperclass annotation) with the
     * load xml flag turned off. Therefore we must make sure we preProcess the
     * accessor again. 
     */
    protected boolean shouldPreProcess(ClassAccessor accessor) {
        MetadataClass cls = (MetadataClass) accessor.getAccessibleObject();
       
        if (accessor.isPreProcessed() && factory.isRoundElement(cls)) {
            accessor.clearPreProcessed();
        }
       
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.