Search in sources :

Example 1 with EmbeddableAccessor

use of org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EmbeddableAccessor in project eclipselink by eclipse-ee4j.

the class MappingAccessor method processEmbeddableMapKeyClass.

/**
 * INTERNAL:
 */
protected AggregateObjectMapping processEmbeddableMapKeyClass(MappedKeyMapAccessor mappedKeyMapAccessor) {
    AggregateObjectMapping keyMapping = new AggregateObjectMapping();
    MetadataClass mapKeyClass = mappedKeyMapAccessor.getMapKeyClass();
    keyMapping.setReferenceClassName(mapKeyClass.getName());
    // The embeddable accessor must be processed by now. If it is not then
    // we are in trouble since by the time we get here, we are too late in
    // the cycle to process embeddable classes and their accessors. See
    // MetadataProject processStage3(), processEmbeddableMappingAccessors.
    // At this stage all class accessors (embeddable, entity and mapped
    // superclass) have to have been processed to gather all their
    // relational and embedded mappings.
    EmbeddableAccessor mapKeyAccessor = getProject().getEmbeddableAccessor(mapKeyClass);
    // Ensure the reference descriptor is marked as an embeddable collection.
    mapKeyAccessor.getDescriptor().setIsEmbeddable();
    // Process the attribute overrides for this may key embeddable.
    processAttributeOverrides(mappedKeyMapAccessor.getMapKeyAttributeOverrides(), keyMapping, mapKeyAccessor.getDescriptor());
    // Process the association overrides for this may key embeddable.
    processAssociationOverrides(mappedKeyMapAccessor.getMapKeyAssociationOverrides(), keyMapping, mapKeyAccessor.getDescriptor());
    // Process a convert key or jpa converter for the map key if specified.
    processConverts(getMapKeyConverts(mappedKeyMapAccessor.getMapKeyConverts()), keyMapping, mappedKeyMapAccessor.getMapKeyClass(), true);
    keyMapping.setDescriptor(getDescriptor().getClassDescriptor());
    return keyMapping;
}
Also used : AggregateObjectMapping(org.eclipse.persistence.mappings.AggregateObjectMapping) MetadataClass(org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataClass) EmbeddableAccessor(org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EmbeddableAccessor)

Example 2 with EmbeddableAccessor

use of org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EmbeddableAccessor in project eclipselink by eclipse-ee4j.

the class MetadataProject method processStage3.

/**
 * INTERNAL:
 * Stage 3 processing does all the extra processing that couldn't be
 * completed in the first two stages of processing. The biggest thing
 * being that all entities will have processed an id by now and we can
 * process those accessors that rely on them. NOTE: The order of invocation
 * here is very important here, see the comments.
 */
public void processStage3(PersistenceUnitProcessor.Mode mode) {
    if (mode == PersistenceUnitProcessor.Mode.ALL || mode == PersistenceUnitProcessor.Mode.COMPOSITE_MEMBER_MIDDLE) {
        // 1 - Process accessors with IDs derived from relationships. This will
        // finish up any stage2 processing that relied on the PK processing
        // being complete as well. Note: some relationships mappings may be
        // processed in this stage. This is ok since it is to determine and
        // validate the primary key.
        processAccessorsWithDerivedIDs();
        // 2 - Process all the direct collection accessors we found. This list
        // does not include direct collections to an embeddable class.
        processDirectCollectionAccessors();
        // 3 - Process the sequencing metadata now that every entity has a
        // validated primary key.
        processSequencingAccessors();
        // 4 - Process the owning relationship accessors now that every entity
        // has a validated primary key and we can process join columns.
        processOwningRelationshipAccessors();
        // 5 - Process the embeddable mapping accessors. These are the
        // embedded, embedded id and element collection accessors that map
        // to an embeddable class. We must hold off on their processing till
        // now to ensure their owning relationship accessors have been processed
        // and we can therefore process any association overrides correctly.
        processEmbeddableMappingAccessors();
        // composite persistence unit case
        if (getCompositeProcessor() != null) {
            for (EmbeddableAccessor accessor : getEmbeddableAccessors()) {
                if (!accessor.isProcessed()) {
                    accessor.process();
                }
            }
        }
    }
    if (mode == PersistenceUnitProcessor.Mode.ALL || mode == PersistenceUnitProcessor.Mode.COMPOSITE_MEMBER_FINAL) {
        // 6 - Process the non owning relationship accessors now that every
        // owning relationship should be fully processed.
        processNonOwningRelationshipAccessors();
        // 7 - Process the interface accessors which will iterate through all
        // the entities in the PU and check if we should add them to a variable
        // one to one mapping that was either defined (incompletely) or
        // defaulted.
        processInterfaceAccessors();
        processPartitioning();
    }
}
Also used : EmbeddableAccessor(org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EmbeddableAccessor)

Example 3 with EmbeddableAccessor

use of org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EmbeddableAccessor in project eclipselink by eclipse-ee4j.

the class MetadataProject method getEmbeddableAccessor.

/**
 * 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) {
        // so desire.
        if (cls.isAnnotationPresent(JPA_EMBEDDABLE) || (checkIsIdClass && isIdClass(cls))) {
            accessor = new EmbeddableAccessor(cls.getAnnotation(JPA_EMBEDDABLE), cls, this);
            addEmbeddableAccessor(accessor);
        }
    }
    return accessor;
}
Also used : EmbeddableAccessor(org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EmbeddableAccessor)

Example 4 with EmbeddableAccessor

use of org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EmbeddableAccessor in project eclipselink by eclipse-ee4j.

the class MetadataDescriptor method processMappingAccessors.

/**
 * INTERNAL:
 * Process this descriptors mapping accessors. Some accessors will not be
 * processed right away, instead stored on the project for processing in a
 * later  stage. This method can not and must not be called beyond
 * MetadataProject stage 2 processing.
 */
public void processMappingAccessors() {
    for (MappingAccessor accessor : m_mappingAccessors.values()) {
        if (!accessor.isProcessed()) {
            // key, process that embeddable accessor now.
            if (accessor.isMappedKeyMapAccessor()) {
                MappedKeyMapAccessor mapAccessor = (MappedKeyMapAccessor) accessor;
                EmbeddableAccessor mapKeyEmbeddableAccessor = getProject().getEmbeddableAccessor(mapAccessor.getMapKeyClass());
                if (mapKeyEmbeddableAccessor != null && !mapKeyEmbeddableAccessor.isProcessed()) {
                    mapKeyEmbeddableAccessor.process();
                }
            }
            // Care must be taken in the order of checking here.
            if (accessor.isDirectEmbeddableCollection() || accessor.isEmbedded()) {
                EmbeddableAccessor embeddableAccessor = getProject().getEmbeddableAccessor(accessor.getReferenceClass());
                // not an Embeddable.
                if (embeddableAccessor == null) {
                    throw ValidationException.invalidEmbeddedAttribute(getJavaClass(), accessor.getAttributeName(), accessor.getReferenceClass());
                } else {
                    // Process the embeddable class now (if it's not already processed)
                    if (!embeddableAccessor.isProcessed()) {
                        embeddableAccessor.process();
                    }
                    // Store this descriptor metadata. It may be needed again
                    // later on to look up a mappedBy attribute etc.
                    addEmbeddableDescriptor(embeddableAccessor.getDescriptor());
                    // accessors have processed.
                    if (accessor.isEmbeddedId() || accessor.isDerivedIdClass()) {
                        accessor.process();
                    } else {
                        // Otherwise defer it because of association overrides.
                        // We can't process this mapping till all the
                        // relationship mappings have been processed.
                        getProject().addEmbeddableMappingAccessor(accessor);
                    }
                }
            } else if (accessor.isDirectCollection()) {
                getProject().addDirectCollectionAccessor(accessor);
            } else if (accessor.isRelationship()) {
                if (accessor.derivesId()) {
                    m_derivedIdAccessors.add((ObjectAccessor) accessor);
                    getProject().addAccessorWithDerivedId(m_classAccessor);
                } else {
                    addRelationshipAccessor((RelationshipAccessor) accessor);
                }
            } else {
                accessor.process();
            }
        }
    }
}
Also used : MappingAccessor(org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.MappingAccessor) MappedKeyMapAccessor(org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.MappedKeyMapAccessor) EmbeddableAccessor(org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EmbeddableAccessor)

Example 5 with EmbeddableAccessor

use of org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EmbeddableAccessor in project eclipselink by eclipse-ee4j.

the class PersistenceUnit method addEmbeddableAccessor.

/**
 * INTERNAL:
 * Add an embeddable accessor to the project, preserving any previous
 * owning descriptors set if applicable.
 */
protected void addEmbeddableAccessor(EmbeddableAccessor embeddableAccessor) {
    // this setting)
    if (project.hasEmbeddable(embeddableAccessor.getJavaClass())) {
        EmbeddableAccessor existingEmbeddableAccessor = project.getEmbeddableAccessor(embeddableAccessor.getJavaClass());
        embeddableAccessor.addEmbeddingAccessors(existingEmbeddableAccessor.getEmbeddingAccessors());
        embeddableAccessor.addOwningDescriptors(existingEmbeddableAccessor.getOwningDescriptors());
    }
    project.addEmbeddableAccessor(embeddableAccessor);
}
Also used : EmbeddableAccessor(org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EmbeddableAccessor)

Aggregations

EmbeddableAccessor (org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EmbeddableAccessor)16 EntityAccessor (org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor)5 ArrayList (java.util.ArrayList)4 MetadataClass (org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataClass)4 HashMap (java.util.HashMap)3 MappedSuperclassAccessor (org.eclipse.persistence.internal.jpa.metadata.accessors.classes.MappedSuperclassAccessor)3 PLSQLParameterMetadata (org.eclipse.persistence.internal.jpa.metadata.queries.PLSQLParameterMetadata)3 ArrayAccessor (org.eclipse.persistence.internal.jpa.metadata.structures.ArrayAccessor)3 StructMetadata (org.eclipse.persistence.internal.jpa.metadata.structures.StructMetadata)3 XMLEntityMappings (org.eclipse.persistence.internal.jpa.metadata.xml.XMLEntityMappings)3 ConverterAccessor (org.eclipse.persistence.internal.jpa.metadata.accessors.classes.ConverterAccessor)2 MappingAccessor (org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.MappingAccessor)2 PersistenceUnitInfo (jakarta.persistence.spi.PersistenceUnitInfo)1 URL (java.net.URL)1 List (java.util.List)1 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)1 DatabaseField (org.eclipse.persistence.internal.helper.DatabaseField)1 MetadataDescriptor (org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor)1 ClassAccessor (org.eclipse.persistence.internal.jpa.metadata.accessors.classes.ClassAccessor)1 XMLAttributes (org.eclipse.persistence.internal.jpa.metadata.accessors.classes.XMLAttributes)1