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));
}
}
}
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));
}
}
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());
}
}
}
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));
}
}
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);
}
}
}
}
Aggregations