Search in sources :

Example 1 with MetadataAnnotation

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

the class MappingAccessor method processProperties.

/**
 * INTERNAL:
 * Adds properties to the mapping.
 */
protected void processProperties(DatabaseMapping mapping) {
    // only. Otherwise look for annotations.
    if (loadedFromXML()) {
        for (PropertyMetadata property : getProperties()) {
            processProperty(mapping, property);
        }
    } else {
        // Look for annotations.
        MetadataAnnotation properties = getAnnotation(Properties.class);
        if (properties != null) {
            for (Object property : properties.getAttributeArray("value")) {
                processProperty(mapping, new PropertyMetadata((MetadataAnnotation) property, this));
            }
        }
        MetadataAnnotation property = getAnnotation(Property.class);
        if (property != null) {
            processProperty(mapping, new PropertyMetadata(property, this));
        }
    }
}
Also used : PropertyMetadata(org.eclipse.persistence.internal.jpa.metadata.accessors.PropertyMetadata) MetadataAccessibleObject(org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAccessibleObject) MetadataAnnotation(org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAnnotation)

Example 2 with MetadataAnnotation

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

the class ClassAccessor method processAttributeOverrides.

/**
 * INTERNAL:
 * Process the attribute override metadata specified on an entity or
 * mapped superclass. Once the attribute overrides are processed from
 * XML process the attribute overrides from annotations. This order of
 * processing must be maintained.
 */
protected void processAttributeOverrides() {
    // Process the XML attribute overrides first.
    for (AttributeOverrideMetadata attributeOverride : m_attributeOverrides) {
        // Process the attribute override.
        processAttributeOverride(attributeOverride);
    }
    // Process the attribute override annotations.
    // Look for an @AttributeOverrides.
    MetadataAnnotation attributeOverrides = getAnnotation(JPA_ATTRIBUTE_OVERRIDES);
    if (attributeOverrides != null) {
        for (Object attributeOverride : attributeOverrides.getAttributeArray("value")) {
            processAttributeOverride(new AttributeOverrideMetadata((MetadataAnnotation) attributeOverride, this));
        }
    }
    // Look for an @AttributeOverride.
    MetadataAnnotation attributeOverride = getAnnotation(JPA_ATTRIBUTE_OVERRIDE);
    if (attributeOverride != null) {
        processAttributeOverride(new AttributeOverrideMetadata(attributeOverride, this));
    }
}
Also used : AttributeOverrideMetadata(org.eclipse.persistence.internal.jpa.metadata.columns.AttributeOverrideMetadata) MetadataAccessibleObject(org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAccessibleObject) OracleObject(org.eclipse.persistence.platform.database.oracle.annotations.OracleObject) MetadataAnnotation(org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAnnotation)

Example 3 with MetadataAnnotation

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

the class ClassAccessor method processCopyPolicy.

/**
 * INTERNAL:
 */
protected void processCopyPolicy() {
    MetadataAnnotation copyPolicy = getAnnotation(CopyPolicy.class);
    MetadataAnnotation instantiationCopyPolicy = getAnnotation(InstantiationCopyPolicy.class);
    MetadataAnnotation cloneCopyPolicy = getAnnotation(CloneCopyPolicy.class);
    if (getCopyPolicy() != null || copyPolicy != null || instantiationCopyPolicy != null || cloneCopyPolicy != null) {
        if (getDescriptor().hasCopyPolicy()) {
            // We must be processing a mapped superclass ...
            getLogger().logConfigMessage(MetadataLogger.IGNORE_MAPPED_SUPERCLASS_COPY_POLICY, getDescriptor().getJavaClass(), getJavaClass());
        }
        if (getCopyPolicy() == null) {
            // Look at the annotations.
            if (copyPolicy != null) {
                if (instantiationCopyPolicy != null || cloneCopyPolicy != null) {
                    throw ValidationException.multipleCopyPolicyAnnotationsOnSameClass(getJavaClassName());
                }
                new CustomCopyPolicyMetadata(copyPolicy, this).process(getDescriptor());
            }
            if (instantiationCopyPolicy != null) {
                if (cloneCopyPolicy != null) {
                    throw ValidationException.multipleCopyPolicyAnnotationsOnSameClass(getJavaClassName());
                }
                new InstantiationCopyPolicyMetadata(instantiationCopyPolicy, this).process(getDescriptor());
            }
            if (cloneCopyPolicy != null) {
                new CloneCopyPolicyMetadata(cloneCopyPolicy, this).process(getDescriptor());
            }
        } else {
            // We have a copy policy specified in XML.
            if (copyPolicy != null) {
                getLogger().logConfigMessage(MetadataLogger.OVERRIDE_ANNOTATION_WITH_XML, copyPolicy, getJavaClassName(), getLocation());
            }
            if (instantiationCopyPolicy != null) {
                getLogger().logConfigMessage(MetadataLogger.OVERRIDE_ANNOTATION_WITH_XML, instantiationCopyPolicy, getJavaClassName(), getLocation());
            }
            if (cloneCopyPolicy != null) {
                getLogger().logConfigMessage(MetadataLogger.OVERRIDE_ANNOTATION_WITH_XML, cloneCopyPolicy, getJavaClassName(), getLocation());
            }
            getCopyPolicy().process(getDescriptor());
        }
    }
}
Also used : InstantiationCopyPolicyMetadata(org.eclipse.persistence.internal.jpa.metadata.copypolicy.InstantiationCopyPolicyMetadata) CloneCopyPolicyMetadata(org.eclipse.persistence.internal.jpa.metadata.copypolicy.CloneCopyPolicyMetadata) CustomCopyPolicyMetadata(org.eclipse.persistence.internal.jpa.metadata.copypolicy.CustomCopyPolicyMetadata) MetadataAnnotation(org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAnnotation)

Example 4 with MetadataAnnotation

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

the class ClassAccessor method processAssociationOverrides.

/**
 * INTERNAL:
 * Process the association override metadata specified on an entity or
 * mapped superclass. Once the association overrides are processed from
 * XML process the association overrides from annotations. This order of
 * processing must be maintained.
 */
protected void processAssociationOverrides() {
    // Process the XML association override elements first.
    for (AssociationOverrideMetadata associationOverride : m_associationOverrides) {
        // Process the association override.
        processAssociationOverride(associationOverride);
    }
    // Process the association override annotations.
    // Look for an @AssociationOverrides.
    MetadataAnnotation associationOverrides = getAnnotation(JPA_ASSOCIATION_OVERRIDES);
    if (associationOverrides != null) {
        for (Object associationOverride : associationOverrides.getAttributeArray("value")) {
            processAssociationOverride(new AssociationOverrideMetadata((MetadataAnnotation) associationOverride, this));
        }
    }
    // Look for an @AssociationOverride.
    MetadataAnnotation associationOverride = getAnnotation(JPA_ASSOCIATION_OVERRIDE);
    if (associationOverride != null) {
        processAssociationOverride(new AssociationOverrideMetadata(associationOverride, this));
    }
}
Also used : AssociationOverrideMetadata(org.eclipse.persistence.internal.jpa.metadata.columns.AssociationOverrideMetadata) MetadataAccessibleObject(org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAccessibleObject) OracleObject(org.eclipse.persistence.platform.database.oracle.annotations.OracleObject) MetadataAnnotation(org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAnnotation)

Example 5 with MetadataAnnotation

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

the class EntityAccessor method processSecondaryTables.

/**
 * INTERNAL:
 * Process secondary-table(s) for a given entity.
 */
protected void processSecondaryTables() {
    // Ignore secondary tables when the descriptor is an EIS descriptor.
    if (!getDescriptor().getClassDescriptor().isEISDescriptor()) {
        MetadataAnnotation secondaryTable = getAnnotation(JPA_SECONDARY_TABLE);
        MetadataAnnotation secondaryTables = getAnnotation(JPA_SECONDARY_TABLES);
        if (m_secondaryTables.isEmpty()) {
            // Look for a SecondaryTables annotation.
            if (secondaryTables != null) {
                for (Object table : secondaryTables.getAttributeArray("value")) {
                    processSecondaryTable(new SecondaryTableMetadata((MetadataAnnotation) table, this));
                }
            } else {
                // Look for a SecondaryTable annotation
                if (secondaryTable != null) {
                    processSecondaryTable(new SecondaryTableMetadata(secondaryTable, this));
                }
            }
        } else {
            if (secondaryTable != null) {
                getLogger().logConfigMessage(MetadataLogger.OVERRIDE_ANNOTATION_WITH_XML, secondaryTable, getJavaClassName(), getLocation());
            }
            if (secondaryTables != null) {
                getLogger().logConfigMessage(MetadataLogger.OVERRIDE_ANNOTATION_WITH_XML, secondaryTables, getJavaClassName(), getLocation());
            }
            for (SecondaryTableMetadata table : m_secondaryTables) {
                processSecondaryTable(table);
            }
        }
    }
}
Also used : SecondaryTableMetadata(org.eclipse.persistence.internal.jpa.metadata.tables.SecondaryTableMetadata) MetadataAccessibleObject(org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAccessibleObject) MetadataAnnotation(org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAnnotation)

Aggregations

MetadataAnnotation (org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAnnotation)24 MetadataAccessibleObject (org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAccessibleObject)13 SerializedObject (org.eclipse.persistence.annotations.SerializedObject)6 MetadataLogger (org.eclipse.persistence.internal.jpa.metadata.MetadataLogger)5 MetadataAsmFactory (org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAsmFactory)5 MetadataClass (org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataClass)5 OracleObject (org.eclipse.persistence.platform.database.oracle.annotations.OracleObject)3 AnnotationValue (javax.lang.model.element.AnnotationValue)1 ExecutableElement (javax.lang.model.element.ExecutableElement)1 HashPartitioning (org.eclipse.persistence.annotations.HashPartitioning)1 Partitioned (org.eclipse.persistence.annotations.Partitioned)1 PinnedPartitioning (org.eclipse.persistence.annotations.PinnedPartitioning)1 RangePartitioning (org.eclipse.persistence.annotations.RangePartitioning)1 ReplicationPartitioning (org.eclipse.persistence.annotations.ReplicationPartitioning)1 RoundRobinPartitioning (org.eclipse.persistence.annotations.RoundRobinPartitioning)1 UnionPartitioning (org.eclipse.persistence.annotations.UnionPartitioning)1 ValuePartitioning (org.eclipse.persistence.annotations.ValuePartitioning)1 VirtualAccessMethods (org.eclipse.persistence.annotations.VirtualAccessMethods)1 MetadataDescriptor (org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor)1 PropertyMetadata (org.eclipse.persistence.internal.jpa.metadata.accessors.PropertyMetadata)1