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

Examples of org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EmbeddableAccessor


            // 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.addEntityAccessor(new EntityAccessor(PersistenceUnitProcessor.getEntityAnnotation(candidateClass), candidateClass, m_project));
                } else if (PersistenceUnitProcessor.isEmbeddable(candidateClass) && ! m_project.hasEmbeddable(candidateClass)) {
                    m_project.addEmbeddableAccessor(new EmbeddableAccessor(PersistenceUnitProcessor.getEmbeddableAnnotation(candidateClass), candidateClass, m_project));
                }
            }
           
            // Mapped-superclasses will be discovered automatically.
        }
View Full Code Here


     * more details.
     *
     * Be careful while changing the order of processing.
     */
    protected void processEmbeddableClass() {
        EmbeddableAccessor accessor = getProject().getEmbeddableAccessor(getReferenceClassName());

        if (accessor == null) {
            // Before throwing an exception we must make one final check for
            // an Embeddable annotation on the referenced class. At this point
            // we know the referenced class was not tagged as an embeddable
            // in a mapping file and was not included in the list of classes
            // 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);
            }
        }
       
        if (accessor.isProcessed()) {
            // We have already processed this embeddable class. Let's validate
            // that it is not used in entities with conflicting access type
            // when the embeddable doesn't have its own explicit setting. The
            // biggest mistake that could occur otherwise is that FIELD
            // processing 'could' yield a different mapping set then PROPERTY
            // processing would. Do we really care? If both access types
            // yielded the same mappings then the only difference would be
            // how they are accessed and well ... does it really matter at this
            // point? The only way to know if they would yield different
            // mappings would be by processing the class for each access type
            // and comparing the yield or some other code to manually inspect
            // the class. I think this error should be removed since the spec
            // states:
            //  "Embedded objects belong strictly to their owning entity, and
            //   are not sharable across persistent entities. Attempting to
            //   share an embedded object across entities has undefined
            //   semantics."
            // I think we should assume the users know what they are are doing
            // in this case (that is, if they opt to share an embeddable).
            if (! accessor.hasAccess()) {
                // We inherited our access from our owning entity.
                if (! accessor.getDescriptor().getDefaultAccess().equals(getOwningDescriptor().getDefaultAccess())) {
                    throw ValidationException.conflictingAccessTypeForEmbeddable(accessor.getJavaClass(), accessor.usesPropertyAccess(), getOwningDescriptor().getJavaClass(), getOwningDescriptor().getClassAccessor().usesPropertyAccess());
                }
            }
        } else {
            // Need to set the owning descriptor on the embeddable class before
            // we proceed any further in the processing.
            accessor.setOwningDescriptor(getOwningDescriptor());
            accessor.process();
            accessor.setIsProcessed();   
        }
    }
View Full Code Here

     * INTERNAL:
     * This method will attempt to look up the embeddable accessor for the
     * reference class provided. If no accessor is found, null is returned.
     */
    public EmbeddableAccessor getEmbeddableAccessor(MetadataClass cls, boolean checkIsIdClass) {
        EmbeddableAccessor accessor = m_embeddableAccessors.get(cls.getName());

        if (accessor == null) {
            // Before we return null we must make a couple final checks:
            //
            // 1 - Check for an Embeddable annotation on the class itself. At
            // this point we know the class was not tagged as an embeddable in
            // a mapping file and was not included in the list of classes for
            // this persistence unit. Its inclusion therefore in the persistence
            // unit is through the use of an Embedded annotation or an embedded
            // element within a known entity.
            // 2 - If checkIsIdClass is true, JPA 2.0 introduced support for
            //
            // derived id's where a parent entity's id class may be used within
            // a dependants embedded id class. We will treat the id class as
            // and embeddable accessor at this point.
            //
            // Callers to this method will have to handle the null case if they
            // so desire.
            if (cls.isAnnotationPresent(JPA_EMBEDDABLE) || (checkIsIdClass && isIdClass(cls))) {
                accessor = new EmbeddableAccessor(cls.getAnnotation(JPA_EMBEDDABLE), cls, this);
                addEmbeddableAccessor(accessor);
            }
       }
       
       return accessor;
View Full Code Here

                // 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));
                    } else if (PersistenceUnitProcessor.isEmbeddable(candidateClass) && ! m_project.hasEmbeddable(candidateClass) && ! m_project.hasEntity(candidateClass)) {
                        m_project.addEmbeddableAccessor(new EmbeddableAccessor(PersistenceUnitProcessor.getEmbeddableAnnotation(candidateClass), candidateClass, m_project));
                    } else if (PersistenceUnitProcessor.isStaticMetamodelClass(candidateClass)) {
                        m_project.addStaticMetamodelClass(PersistenceUnitProcessor.getStaticMetamodelAnnotation(candidateClass), candidateClass);
                    }
                }
               
View Full Code Here

            // 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.addEntityAccessor(new EntityAccessor(PersistenceUnitProcessor.getEntityAnnotation(candidateClass), candidateClass, m_project));
                } else if (PersistenceUnitProcessor.isEmbeddable(candidateClass) && ! m_project.hasEmbeddable(candidateClass)) {
                    m_project.addEmbeddableAccessor(new EmbeddableAccessor(PersistenceUnitProcessor.getEmbeddableAnnotation(candidateClass), candidateClass, m_project));
                }
            }
           
            // Mapped-superclasses will be discovered automatically.
        }
View Full Code Here

                // 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));
                    } else if (PersistenceUnitProcessor.isEmbeddable(candidateClass) && ! m_project.hasEmbeddable(candidateClass) && ! m_project.hasEntity(candidateClass)) {
                        m_project.addEmbeddableAccessor(new EmbeddableAccessor(PersistenceUnitProcessor.getEmbeddableAnnotation(candidateClass), candidateClass, m_project));
                    } else if (PersistenceUnitProcessor.isStaticMetamodelClass(candidateClass)) {
                        m_project.addStaticMetamodelClass(PersistenceUnitProcessor.getStaticMetamodelAnnotation(candidateClass), candidateClass);
                    }
                }
               
View Full Code Here

     * INTERNAL:
     * This method will attempt to look up the embeddable accessor for the
     * reference class provided. If no accessor is found, null is returned.
     */
    public EmbeddableAccessor getEmbeddableAccessor(MetadataClass cls, boolean checkIsIdClass) {
        EmbeddableAccessor accessor = m_embeddableAccessors.get(cls.getName());

        if (accessor == null) {
            // Before we return null we must make a couple final checks:
            //
            // 1 - Check for an Embeddable annotation on the class itself. At
            // this point we know the class was not tagged as an embeddable in
            // a mapping file and was not included in the list of classes for
            // this persistence unit. Its inclusion therefore in the persistence
            // unit is through the use of an Embedded annotation or an embedded
            // element within a known entity.
            // 2 - If checkIsIdClass is true, JPA 2.0 introduced support for
            //
            // derived id's where a parent entity's id class may be used within
            // a dependants embedded id class. We will treat the id class as
            // and embeddable accessor at this point.
            //
            // Callers to this method will have to handle the null case if they
            // so desire.
            if (cls.isAnnotationPresent(JPA_EMBEDDABLE) || (checkIsIdClass && isIdClass(cls))) {
                accessor = new EmbeddableAccessor(cls.getAnnotation(JPA_EMBEDDABLE), cls, this);
                addEmbeddableAccessor(accessor);
            }
       }
       
       return accessor;
View Full Code Here

     * more details.
     *
     * Be careful while changing the order of processing.
     */
    protected void processEmbeddableClass() {
        EmbeddableAccessor accessor = getProject().getEmbeddableAccessor(getReferenceClassName());

        if (accessor == null) {
            // Before throwing an exception we must make one final check for
            // an Embeddable annotation on the referenced class. At this point
            // we know the referenced class was not tagged as an embeddable
            // in a mapping file and was not included in the list of classes
            // 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);
            }
        }
       
        if (accessor.isProcessed()) {
            // We have already processed this embeddable class. Let's validate
            // that it is not used in entities with conflicting access type
            // when the embeddable doesn't have its own explicit setting. The
            // biggest mistake that could occur otherwise is that FIELD
            // processing 'could' yield a different mapping set then PROPERTY
            // processing would. Do we really care? If both access types
            // yielded the same mappings then the only difference would be
            // how they are accessed and well ... does it really matter at this
            // point? The only way to know if they would yield different
            // mappings would be by processing the class for each access type
            // and comparing the yield or some other code to manually inspect
            // the class. I think this error should be removed since the spec
            // states:
            //  "Embedded objects belong strictly to their owning entity, and
            //   are not sharable across persistent entities. Attempting to
            //   share an embedded object across entities has undefined
            //   semantics."
            // I think we should assume the users know what they are are doing
            // in this case (that is, if they opt to share an embeddable).
            if (! accessor.hasAccess()) {
                // We inherited our access from our owning entity.
                if (! accessor.getDescriptor().getDefaultAccess().equals(getOwningDescriptor().getDefaultAccess())) {
                    throw ValidationException.conflictingAccessTypeForEmbeddable(accessor.getJavaClass(), accessor.usesPropertyAccess(), getOwningDescriptor().getJavaClass(), getOwningDescriptor().getClassAccessor().usesPropertyAccess());
                }
            }
        } else {
            // Need to set the owning descriptor on the embeddable class before
            // we proceed any further in the processing.
            accessor.setOwningDescriptor(getOwningDescriptor());
            accessor.process();
            accessor.setIsProcessed();   
        }
    }
View Full Code Here

            // 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.addEntityAccessor(new EntityAccessor(PersistenceUnitProcessor.getEntityAnnotation(candidateClass), candidateClass, m_project));
                } else if (PersistenceUnitProcessor.isEmbeddable(candidateClass) && ! m_project.hasEmbeddable(candidateClass)) {
                    m_project.addEmbeddableAccessor(new EmbeddableAccessor(PersistenceUnitProcessor.getEmbeddableAnnotation(candidateClass), candidateClass, m_project));
                }
            }
           
            // Mapped-superclasses will be discovered automatically.
        }
View Full Code Here

        // 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(JPA_EMBEDDABLE), metadataClass, project));
                }
            }
        } else if (! excludeUnlistedClasses(metadataClass)) {
            // add it!
            addEmbeddableAccessor(new EmbeddableAccessor(metadataClass.getAnnotation(JPA_EMBEDDABLE), metadataClass, project));
        }
    }
View Full Code Here

TOP

Related Classes of org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EmbeddableAccessor

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.