Search in sources :

Example 1 with MixedConverterMetadata

use of org.eclipse.persistence.internal.jpa.metadata.converters.MixedConverterMetadata in project eclipselink by eclipse-ee4j.

the class XMLEntityMappings method initPersistenceUnitClasses.

/**
 * INTERNAL:
 * Assumes the correct class loader has been set before calling this
 * method.
 */
public void initPersistenceUnitClasses(HashMap<String, EntityAccessor> allEntities, HashMap<String, EmbeddableAccessor> allEmbeddables) {
    // the mixed converter metadata list.
    for (MixedConverterMetadata mixedConverter : m_mixedConverters) {
        if (mixedConverter.isConverterMetadata()) {
            m_converters.add(mixedConverter.buildConverterMetadata());
        } else {
            m_converterAccessors.add(mixedConverter.buildConverterAccessor());
        }
    }
    // Process the entities
    for (EntityAccessor entity : getEntities()) {
        // Initialize the class with the package from entity mappings.
        MetadataClass entityClass = getMetadataClass(getPackageQualifiedClassName(entity.getClassName()), false);
        // Initialize the entity with its metadata descriptor and project.
        // This initialization must be done before a potential merge below.
        entity.initXMLClassAccessor(entityClass, new MetadataDescriptor(entityClass, entity), m_project, this);
        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.
        MetadataClass embeddableClass = getMetadataClass(getPackageQualifiedClassName(embeddable.getClassName()), false);
        // Initialize the embeddable with its metadata descriptor and project.
        // This initialization must be done before a potential merge below.
        embeddable.initXMLClassAccessor(embeddableClass, new MetadataDescriptor(embeddableClass, embeddable), m_project, this);
        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.
        MetadataClass mappedSuperclassClass = getMetadataClass(getPackageQualifiedClassName(mappedSuperclass.getClassName()), false);
        // Initialize the mapped superclass with a metadata descriptor and project.
        // This initialization must be done before a potential merge below.
        mappedSuperclass.initXMLClassAccessor(mappedSuperclassClass, new MetadataDescriptor(mappedSuperclassClass, mappedSuperclass), m_project, this);
        if (m_project.hasMappedSuperclass(mappedSuperclassClass)) {
            // Merge this mapped superclass with the existing one.
            m_project.getMappedSuperclassAccessor(mappedSuperclassClass).merge(mappedSuperclass);
        } else {
            // Add this mapped superclass to the project.
            m_project.addMappedSuperclass(mappedSuperclass);
        }
    }
    // Process the JPA converter classes.
    for (ConverterAccessor converterAccessor : m_converterAccessors) {
        // Initialize the class with the package from entity mappings.
        MetadataClass converterClass = getMetadataClass(getPackageQualifiedClassName(converterAccessor.getClassName()), false);
        // Initialize the converter class.
        // This initialization must be done before a potential merge below.
        converterAccessor.initXMLObject(converterClass, this);
        if (m_project.hasConverterAccessor(converterClass)) {
            // Merge this converter with the existing one (will check for discrepancies between them)
            m_project.getConverterAccessor(converterClass).merge(converterAccessor);
        } else {
            // Add this converter to the project.
            m_project.addConverterAccessor(converterAccessor);
        }
    }
}
Also used : EntityAccessor(org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor) MappedSuperclassAccessor(org.eclipse.persistence.internal.jpa.metadata.accessors.classes.MappedSuperclassAccessor) MixedConverterMetadata(org.eclipse.persistence.internal.jpa.metadata.converters.MixedConverterMetadata) MetadataClass(org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataClass) ConverterAccessor(org.eclipse.persistence.internal.jpa.metadata.accessors.classes.ConverterAccessor) MetadataDescriptor(org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor) EmbeddableAccessor(org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EmbeddableAccessor)

Aggregations

MetadataDescriptor (org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor)1 ConverterAccessor (org.eclipse.persistence.internal.jpa.metadata.accessors.classes.ConverterAccessor)1 EmbeddableAccessor (org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EmbeddableAccessor)1 EntityAccessor (org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor)1 MappedSuperclassAccessor (org.eclipse.persistence.internal.jpa.metadata.accessors.classes.MappedSuperclassAccessor)1 MetadataClass (org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataClass)1 MixedConverterMetadata (org.eclipse.persistence.internal.jpa.metadata.converters.MixedConverterMetadata)1