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

Examples of org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor


     */
    protected void processTableAndInheritance() {
        // If we are an inheritance subclass, ensure our root is processed
        // first since it has information its subclasses depend on.
        if (getDescriptor().isInheritanceSubclass()) {
            MetadataDescriptor rootDescriptor = getDescriptor().getInheritanceRootDescriptor();
            EntityAccessor rootAccessor = (EntityAccessor) rootDescriptor.getClassAccessor();
           
            // An entity who didn't know they were the root of an inheritance
            // hierarchy (that is, does not define inheritance metadata) must
            // process and default the inheritance metadata.
            if (! rootAccessor.hasInheritance()) {   
                rootAccessor.processInheritance();
            }
           
            // Process the table metadata for this descriptor if either there
            // is an inheritance specification (we're a new root) or if we are
            // part of a joined or table per class inheritance strategy.
            if (hasInheritance() || ! rootDescriptor.usesSingleTableInheritanceStrategy()) {
                processTable();
            }
           
            // If this entity has inheritance metadata as well, then the
            // inheritance strategy is mixed and we need to process the
View Full Code Here


        keyMapping.dontUseIndirection();
        keyMapping.setDescriptor(getDescriptor().getClassDescriptor());
       
        // Process the map key join columns.
        EntityAccessor mapKeyAccessor = getProject().getEntityAccessor(mapKeyClassName);
        MetadataDescriptor mapKeyClassDescriptor = mapKeyAccessor.getDescriptor();
       
        // If the fk field (name) is not specified, it defaults to the
        // concatenation of the following: the name of the referencing
        // relationship property or field of the referencing entity or
        // embeddable; "_"; "KEY"
View Full Code Here

   
    /**
     * INTERNAL:
     */
    public ClassAccessor(MetadataAnnotation annotation, MetadataClass cls, MetadataProject project) {
        super(annotation, cls, new MetadataDescriptor(cls), project);
       
        // Set the class accessor reference on the descriptor.
        getDescriptor().setClassAccessor(this);
       
        // Look for an explicit access type specification.
View Full Code Here

               
                // 266912: process and store mappedSuperclass descriptors on the
                // project for later use by the Metamodel API Note: we must
                // again reload our accessor from XML or we will be sharing
                // instances of the descriptor
                getProject().addMetamodelMappedSuperclass(reloadMappedSuperclass(accessor,  new MetadataDescriptor(metadataClass)), getDescriptor());
            } else {
                m_mappedSuperclasses.add(accessor);
            }
        }
    }
View Full Code Here

            processing.add(this);
           
            for (ObjectAccessor accessor : getDescriptor().getDerivedIdAccessors()) {
                // Check the reference accessor for a derived id and fast
                // track its processing if need be.
                MetadataDescriptor referenceDescriptor = accessor.getReferenceDescriptor();
                ClassAccessor referenceAccessor = referenceDescriptor.getClassAccessor();
               
                if (referenceAccessor.hasDerivedId()) {   
                    referenceAccessor.processDerivedId(processing, processed);
                }
               
View Full Code Here

     * INTERNAL:
     * Process a map key for a 1-M or M-M mapping. Will return the map key
     * method name that should be use, null otherwise.
     */
    public String process(ContainerMapping mapping, MappingAccessor mappingAccessor) {
        MetadataDescriptor referenceDescriptor = mappingAccessor.getReferenceDescriptor();
        MetadataLogger logger = mappingAccessor.getLogger();
       
        if ((! hasName()) && referenceDescriptor.hasCompositePrimaryKey()) {
            // No persistent property or field name has been provided, and the
            // reference class has a composite primary key class.  Return null,
            // internally, EclipseLink will use an instance of the composite
            // primary key class as the map key.
            return null;
        } else {
            // A persistent property or field name may have have been provided.
            // If one has not we will default to the primary key of the reference
            // class. The primary key cannot be composite at this point.
            String fieldOrPropertyName = MetadataHelper.getName(m_name, referenceDescriptor.getIdAttributeName(), logger.MAP_KEY_ATTRIBUTE_NAME, logger, mappingAccessor.getAnnotatedElementName());
   
            // Look up the referenceAccessor
            MetadataAccessor referenceAccessor = referenceDescriptor.getMappingAccessor(fieldOrPropertyName);
            if (referenceAccessor == null) {
                // 266912: relax validation for MappedSuperclass descriptors when the map key is an unresolved generic type
                if (referenceDescriptor.isMappedSuperclass()) {
                    return null;
                } else {
                    throw ValidationException.couldNotFindMapKey(fieldOrPropertyName, referenceDescriptor.getJavaClass(), (DatabaseMapping)mapping);
                }
            }
       
            return referenceAccessor.getAccessibleObjectName();
        }
View Full Code Here

    /**
     * INTERNAL:
     */
    public void process(ClassAccessor accessor) {
        MetadataDescriptor descriptor = accessor.getDescriptor();
       
        FetchGroupManager fetchGroupManager;
        if (descriptor.getClassDescriptor().hasFetchGroupManager()) {
            fetchGroupManager = descriptor.getClassDescriptor().getFetchGroupManager();
        } else {
            fetchGroupManager = new FetchGroupManager();
            descriptor.getClassDescriptor().setFetchGroupManager(fetchGroupManager);
        }
       
        if (fetchGroupManager.hasFetchGroup(m_name)) {
            // We must be adding a fetch group from a mapped superclass.
            // Entity fetch groups are added first followed by those from
            // mapped superclasses. So if one already exists we need to ignore
            // it.
            getLogger().logConfigMessage(MetadataLogger.IGNORE_MAPPED_SUPERCLASS_FETCH_GROUP, descriptor.getJavaClass(), accessor.getJavaClass(), m_name);
        } else {
            FetchGroup fetchGroup = new FetchGroup();
           
            // Process the name of the fetch group.
            fetchGroup.setName(m_name);
View Full Code Here

     * process itself if it hasn't already done so. Assumes that a mapped by
     * value has been specified and that a check against mappedBy has been
     * done.
     */
    protected DatabaseMapping getOwningMapping() {
        MetadataDescriptor ownerDescriptor = getReferenceDescriptor();
        MappingAccessor mappingAccessor = ownerDescriptor.getMappingAccessor(getMappedBy());
       
        // If no mapping was found, there is an error in the mappedBy field,
        // therefore, throw an exception.
        if (mappingAccessor == null) {
            throw ValidationException.noMappedByAttributeFound(ownerDescriptor.getJavaClass(), getMappedBy(), getJavaClass(), getAttributeName());
        } else if (mappingAccessor.isRelationship()) {
            RelationshipAccessor relationshipAccessor = (RelationshipAccessor) mappingAccessor;
           
            // Check that we don't have circular mappedBy values which will
            // cause an infinite loop.
View Full Code Here

      * This method does additional checks to make sure that the target
      * entity is indeed an entity class.
      */
    @Override
    public MetadataDescriptor getReferenceDescriptor() {
        MetadataDescriptor referenceDescriptor;
       
        // When processing metamodel mapped superclasses, we don't have the
        // luxury of a full type context as we would during regular metadata
        // processing (e.g. to figure out generic types). The metamodel mapped
        // superclass descriptors must therefore rely on a real child descriptor
        // to extract this information and process correctly. When a type is
        // unknown, the reference class name currently defaults to java.lang.string.
        // @see MetadataAnnotatedElement getRawClass(MetadataDescriptor)
        if (getDescriptor().isMappedSuperclass() && getReferenceClassName().equals(MetadataAnnotatedElement.DEFAULT_RAW_CLASS) || getReferenceClass().isVoid()) {
            MappingAccessor childMappingAccessor = getDescriptor().getMetamodelMappedSuperclassChildDescriptor().getMappingAccessor(getAttributeName());
            referenceDescriptor = childMappingAccessor.getReferenceDescriptor();
           
            if (referenceDescriptor.isInheritanceSubclass()) {
                referenceDescriptor = referenceDescriptor.getInheritanceRootDescriptor();
            }
        } else {
            ClassAccessor accessor = getProject().getAccessor(getReferenceClassName());
            referenceDescriptor = (accessor != null) ? accessor.getDescriptor() : null;
            if (referenceDescriptor == null) {
                MetadataProcessor compositeProcessor = getProject().getCompositeProcessor();
                if (compositeProcessor != null) {
                    for (MetadataProject pearProject : compositeProcessor.getPearProjects(getProject())) {
                        accessor = pearProject.getAccessor(getReferenceClassName());
                        if (accessor != null) {
                            referenceDescriptor = accessor.getDescriptor();
                            break;
                        }
                    }
                }
            }
        }
      
        // Validate the reference descriptor is valid.
        if (referenceDescriptor == null || referenceDescriptor.isEmbeddable() || referenceDescriptor.isEmbeddableCollection()) {
            throw ValidationException.nonEntityTargetInRelationship(getJavaClass(), getReferenceClass(), getAnnotatedElement());
        }
      
        return referenceDescriptor;
    }
View Full Code Here

    /**
     * INTERNAL:
     * Used to process primary keys and DerivedIds.
     */
    protected MetadataClass getSimplePKType(){
        MetadataDescriptor referenceDescriptor = getReferenceDescriptor();
        ClassAccessor referenceAccessor = referenceDescriptor.getClassAccessor();
       
        if (referenceAccessor.hasDerivedId()) {
            // Referenced object has a derived ID and must be a simple pk type. 
            // Recurse through to get the simple type.
            return ((ObjectAccessor) referenceDescriptor.getMappingAccessor(referenceDescriptor.getIdAttributeName())).getSimplePKType();
        } else {
            // Validate on their basic mapping.
            return referenceDescriptor.getMappingAccessor(referenceDescriptor.getIdAttributeName()).getRawClass();
        }
    }
View Full Code Here

TOP

Related Classes of org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor

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.