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

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


     * INTERNAL:
     * The process method method will be called with the descriptor from
     * every entity in the hierarchy.
     */
    public void process(MetadataDescriptor descriptor) {
        EntityAccessor accessor = (EntityAccessor) descriptor.getClassAccessor();
       
        // Set the correct inheritance policy.
        if (m_strategy != null && m_strategy.equals(InheritanceType.TABLE_PER_CLASS.name())) {
            setTablePerClassInheritancePolicy(descriptor);
        } else {
            setInheritancePolicy(descriptor);
        }
       
        // Process an inheritance subclass.
        if (descriptor.isInheritanceSubclass()) {
            MetadataDescriptor rootDescriptor = descriptor.getInheritanceRootDescriptor();
            EntityAccessor rootAccessor = (EntityAccessor) rootDescriptor.getClassAccessor();
                
            if (rootDescriptor.usesTablePerClassInheritanceStrategy()) {
                MetadataDescriptor parentDescriptor = descriptor.getInheritanceParentDescriptor();
                descriptor.getClassDescriptor().getTablePerClassPolicy().addParentDescriptor(parentDescriptor.getClassDescriptor());
                parentDescriptor.getClassDescriptor().getTablePerClassPolicy().addChildDescriptor(descriptor.getClassDescriptor());
            } else {
                // Set the parent class on the inheritance policy.
                descriptor.getClassDescriptor().getInheritancePolicy().setParentClassName(descriptor.getInheritanceParentDescriptor().getJavaClassName());               
            }
           
            // If we have inheritance defined then we are a root parent and the
            // strategy should be changing meaning we have double the work to do.
            // Note: if the strategy does not change, then we ignore the inheritance
            // hierarchy and continue as if we were a simple inheritance subclass.
            if (accessor.hasInheritance() && ! equals(rootAccessor.getInheritance())) {
                // If our parent was a table per class strategy then we need
                // to add the table per class mappings.
                if (rootDescriptor.usesTablePerClassInheritanceStrategy()) {
                    // Go through our parents (including their mapped superclasses
                    // and add their accessors to our list of accessors.
                    addTablePerClassParentMappings(descriptor, descriptor);
                } else {
                    if (! usesTablePerClassStrategy()) {
                        // We are either a JOINED or SINGLE_TABLE strategy and we
                        // need to process our specific inheritance metadata.
                        addClassIndicatorField(descriptor, accessor);
                        addClassIndicator(rootDescriptor, accessor);
                    }
                   
                    // The strategies are changing so must process some
                    // join columns to link up the classes.
                    accessor.processInheritancePrimaryKeyJoinColumns();
                }
            } else {
                // We are a simple inheritance subclass.
                if (usesTablePerClassStrategy()) {
                    // Go through our parents (including their mapped superclasses
                    // and add their accessors to our list of accessors.
                    addTablePerClassParentMappings(descriptor, descriptor);
                } else {
                    // We have metadata we need to set on our root parent.
                    addClassIndicator(rootDescriptor, accessor);
                   
                    // Process join columns if necessary.
                    if (rootAccessor.getInheritance().usesJoinedStrategy()) {
                        accessor.processInheritancePrimaryKeyJoinColumns();
                    }
                }
            }
           
View Full Code Here


     *   descriptor, they must be reloaded/cloned and cannot be shared.
     *   Otherwise the processing of those accessor will only be performed once
     *   by their 'real' owning entity accessor.
     */
    public void addTablePerClassParentMappings(MetadataDescriptor startingDescriptor, MetadataDescriptor realDescriptor) {
        EntityAccessor reloadedParentEntity = null;
        MetadataDescriptor realParentDescriptor = null;
       
        // If we are an inheritance subclass, recursively call up to the root
        // entity so that we can grab a copy of all our inherited mapping
        // accessors. Copies of our parent accessors are done by reloading the
        // parent entities through OX (if they were originally loaded from XML).
        // This is our way of cloning. The reloaded accessors are rebuilt using
        // the startingDescriptor context, that is where we want to add the
        // accessors.
        if (realDescriptor.isInheritanceSubclass() && realDescriptor.getInheritanceRootDescriptor().usesTablePerClassInheritanceStrategy()) {
            realParentDescriptor = realDescriptor.getInheritanceParentDescriptor();
            reloadedParentEntity = reloadEntity((EntityAccessor) realParentDescriptor.getClassAccessor(), startingDescriptor);
            addTablePerClassParentMappings(startingDescriptor, realParentDescriptor);
        }
       
        // If we are the starting entity, the processing of our mapped
        // superclass and our accessors will be done when we process our
        // immediate accessors. Also, our immediate mapped superclasses will
        // have other metadata for us to process (and not just the addition of
        // accessors). See EntityAccesor process() and processClassMetadata().
        if (reloadedParentEntity != null) {
            // Be sure to reload the mapped superclass from the 'real' entity
            // accessor which has already discovered the list.
            EntityAccessor realParentEntityAccessor = (EntityAccessor) realParentDescriptor.getClassAccessor();
           
            for (MappedSuperclassAccessor mappedSuperclass : realParentEntityAccessor.getMappedSuperclasses()) {
                // Reload the mapped superclass and add its accessors.
                reloadMappedSuperclass(mappedSuperclass, startingDescriptor).addAccessors();
            }
           
            // Add the mapping accessors from the reloaded entity.
View Full Code Here

           
        // Reload the xml entity mappings object
        xmlEntityMappings = reloadXMLEntityMappingsObject(xmlEntityMappings);
           
        // Initialize the newly loaded/built entity
        EntityAccessor entity = xmlEntityMappings.getEntities().get(0);
        MetadataClass metadataClass = getMetadataFactory().getMetadataClass(getFullClassName(entity.getClassName()));
        entity.initXMLClassAccessor(metadataClass, descriptor, m_project, this);
       
        return entity;
    }
View Full Code Here

* @since EclipseLink 2.5.1
*/
public class EntityImpl extends AbstractMappedClassImpl<EntityAccessor, Entity> implements Entity {
   
    public EntityImpl() {
        super(new EntityAccessor());
       
        getMetadata().setConverts(new ArrayList<ConvertMetadata>());
        getMetadata().setIndexes(new ArrayList<IndexMetadata>());
        getMetadata().setPrimaryKeyJoinColumns(new ArrayList<PrimaryKeyJoinColumnMetadata>());
        getMetadata().setSecondaryTables(new ArrayList<SecondaryTableMetadata>());
View Full Code Here

        keyMapping.setReferenceClassName(mapKeyClassName);
        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

        keyMapping.setReferenceClassName(mapKeyClassName);
        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

           
        // Reload the xml entity mappings object
        xmlEntityMappings = reloadXMLEntityMappingsObject(xmlEntityMappings);
           
        // Initialize the newly loaded/built entity
        EntityAccessor entity = xmlEntityMappings.getEntities().get(0);
        MetadataClass metadataClass = getMetadataFactory().getMetadataClass(getPackageQualifiedClassName(entity.getClassName()));
        entity.initXMLClassAccessor(metadataClass, descriptor, m_project, this);
       
        return entity;
    }
View Full Code Here

     * with the subclasses context (that is, the descriptor we are given).
     */
    protected EntityAccessor reloadEntity(EntityAccessor entity, MetadataDescriptor descriptor) {
        if (getEntityMappings() == null) {
            // Create a new EntityAccesor.
            EntityAccessor entityAccessor = new EntityAccessor(entity.getAnnotation(), entity.getJavaClass(), entity.getProject());
            // Things we care about ...
            descriptor.setDefaultAccess(entity.getDescriptor().getDefaultAccess());
            entityAccessor.setDescriptor(descriptor);
            return entityAccessor;           
        } else {
            return getEntityMappings().reloadEntity(entity, descriptor);
        }
    }
View Full Code Here

     * INTERNAL:
     * The process method method will be called with the descriptor from
     * every entity in the hierarchy.
     */
    public void process(MetadataDescriptor descriptor) {
        EntityAccessor accessor = (EntityAccessor) descriptor.getClassAccessor();
       
        // Set the correct inheritance policy.
        if (m_strategy != null && m_strategy.equals(InheritanceType.TABLE_PER_CLASS.name())) {
            setTablePerClassInheritancePolicy(descriptor);
        } else {
            setInheritancePolicy(descriptor);
        }
       
        // Process an inheritance subclass.
        if (descriptor.isInheritanceSubclass()) {
            MetadataDescriptor rootDescriptor = descriptor.getInheritanceRootDescriptor();
            EntityAccessor rootAccessor = (EntityAccessor) rootDescriptor.getClassAccessor();
                
            if (rootDescriptor.usesTablePerClassInheritanceStrategy()) {
                MetadataDescriptor parentDescriptor = descriptor.getInheritanceParentDescriptor();
                descriptor.getClassDescriptor().getTablePerClassPolicy().addParentDescriptor(parentDescriptor.getClassDescriptor());
                parentDescriptor.getClassDescriptor().getTablePerClassPolicy().addChildDescriptor(descriptor.getClassDescriptor());
            } else {
                // Set the parent class on the inheritance policy.
                descriptor.getClassDescriptor().getInheritancePolicy().setParentClassName(descriptor.getInheritanceParentDescriptor().getJavaClassName());               
            }
           
            // If we have inheritance defined then we are a root parent and the
            // strategy should be changing meaning we have double the work to do.
            // Note: if the strategy does not change, then we ignore the inheritance
            // hierarchy and continue as if we were a simple inheritance subclass.
            if (accessor.hasInheritance() && ! equals(rootAccessor.getInheritance())) {
                // If our parent was a table per class strategy then we need
                // to add the table per class mappings.
                if (rootDescriptor.usesTablePerClassInheritanceStrategy()) {
                    // Go through our parents (including their mapped superclasses
                    // and add their accessors to our list of accessors.
                    addTablePerClassParentMappings(descriptor, descriptor);
                } else {
                    if (! usesTablePerClassStrategy()) {
                        // We are either a JOINED or SINGLE_TABLE strategy and we
                        // need to process our specific inheritance metadata.
                        addClassIndicatorField(descriptor, accessor);
                        addClassIndicator(rootDescriptor, accessor);
                    }
                   
                    // The strategies are changing so must process some
                    // join columns to link up the classes.
                    accessor.processInheritancePrimaryKeyJoinColumns();
                }
            } else {
                // We are a simple inheritance subclass.
                if (usesTablePerClassStrategy()) {
                    // Go through our parents (including their mapped superclasses
                    // and add their accessors to our list of accessors.
                    addTablePerClassParentMappings(descriptor, descriptor);
                } else {
                    // We have metadata we need to set on our root parent.
                    addClassIndicator(rootDescriptor, accessor);
                   
                    // Process join columns if necessary.
                    if (rootAccessor.getInheritance().usesJoinedStrategy()) {
                        accessor.processInheritancePrimaryKeyJoinColumns();
                    }
                }
            }
           
View Full Code Here

     *   descriptor, they must be reloaded/cloned and cannot be shared.
     *   Otherwise the processing of those accessor will only be performed once
     *   by their 'real' owning entity accessor.
     */
    public void addTablePerClassParentMappings(MetadataDescriptor startingDescriptor, MetadataDescriptor realDescriptor) {
        EntityAccessor reloadedParentEntity = null;
        MetadataDescriptor realParentDescriptor = null;
       
        // If we are an inheritance subclass, recursively call up to the root
        // entity so that we can grab a copy of all our inherited mapping
        // accessors. Copies of our parent accessors are done by reloading the
        // parent entities through OX (if they were originally loaded from XML).
        // This is our way of cloning. The reloaded accessors are rebuilt using
        // the startingDescriptor context, that is where we want to add the
        // accessors.
        if (realDescriptor.isInheritanceSubclass() && realDescriptor.getInheritanceRootDescriptor().usesTablePerClassInheritanceStrategy()) {
            realParentDescriptor = realDescriptor.getInheritanceParentDescriptor();
            reloadedParentEntity = reloadEntity((EntityAccessor) realParentDescriptor.getClassAccessor(), startingDescriptor);
            addTablePerClassParentMappings(startingDescriptor, realParentDescriptor);
        }
       
        // If we are the starting entity, the processing of our mapped
        // superclass and our accessors will be done when we process our
        // immediate accessors. Also, our immediate mapped superclasses will
        // have other metadata for us to process (and not just the addition of
        // accessors). See EntityAccesor process() and processClassMetadata().
        if (reloadedParentEntity != null) {
            // Be sure to reload the mapped superclass from the 'real' entity
            // accessor which has already discovered the list.
            EntityAccessor realParentEntityAccessor = (EntityAccessor) realParentDescriptor.getClassAccessor();
           
            for (MappedSuperclassAccessor mappedSuperclass : realParentEntityAccessor.getMappedSuperclasses()) {
                // Reload the mapped superclass and add its accessors.
                reloadMappedSuperclass(mappedSuperclass, startingDescriptor).addAccessors();
            }
           
            // Add the mapping accessors from the reloaded entity.
View Full Code Here

TOP

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

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.