Class MetadataDescriptor


  • public class MetadataDescriptor
    extends Object
    INTERNAL: Common metatata descriptor for the annotation and xml processors. This class is a wrap on an actual EclipseLink descriptor.
    Since:
    TopLink EJB 3.0 Reference Implementation
    Author:
    Guy Pelletier
    • Constructor Detail

      • MetadataDescriptor

        public MetadataDescriptor​(MetadataClass javaClass)
        INTERNAL:
    • Method Detail

      • addConvert

        public void addConvert​(String attributeName,
                               ConvertMetadata convert)
        INTERNAL: Add a convert to override a superclass class mapping.
      • addEmbeddableDescriptor

        public void addEmbeddableDescriptor​(MetadataDescriptor embeddableDescriptor)
        INTERNAL:
      • addEntityListenerEventListener

        public void addEntityListenerEventListener​(DescriptorEventListener listener)
        INTERNAL:
      • addField

        public void addField​(DatabaseField field)
        INTERNAL: Add a field from a basic mapping from this descriptor.
      • addFieldForInsert

        public void addFieldForInsert​(DatabaseField field)
        INTERNAL:
      • addFieldForInsertReturnOnly

        public void addFieldForInsertReturnOnly​(DatabaseField field)
        INTERNAL:
      • addFieldForUpdate

        public void addFieldForUpdate​(DatabaseField field)
        INTERNAL:
      • addForeignKeyFieldForMultipleTable

        public void addForeignKeyFieldForMultipleTable​(DatabaseField fkField,
                                                       DatabaseField pkField)
        INTERNAL:
      • addGenericType

        public void addGenericType​(String genericName,
                                   String type)
        INTERNAL: Add a generic type for this descriptor.
      • addIdAttributeName

        public void addIdAttributeName​(String idAttributeName)
        INTERNAL:
      • addMapKeyConvert

        public void addMapKeyConvert​(String attributeName,
                                     ConvertMetadata convert)
        INTERNAL: Add a map key convert to override a superclass class mapping.
      • addMappingAccessor

        public void addMappingAccessor​(MappingAccessor accessor)
        INTERNAL: If the accessor is an IdAccessor we store it in a separate map for use during MappedSuperclass processing.
      • addProperty

        public void addProperty​(PropertyMetadata property)
        INTERNAL: Add a property to the descriptor. Will check for an override/ignore case.
      • addPrimaryKeyField

        public void addPrimaryKeyField​(DatabaseField field)
        INTERNAL: Add a field representing the primary key or part of a composite primary key to the List of primary key fields on the relational descriptor associated with this metadata descriptor. Call this method if there is no associated mapping accessor, e.g. a PrimaryKey annotation specification or a derived id mapping. Otherwise, regular JPA id mappings should call addPrimaryKeyField(DatabaseField, MappingAccessor)
      • addPrimaryKeyField

        public void addPrimaryKeyField​(DatabaseField field,
                                       MappingAccessor accessor)
        INTERNAL: Add a field representing the primary key or part of a composite primary key to the List of primary key fields on the relational descriptor associated with this metadata descriptor.
      • addRelationshipAccessor

        public void addRelationshipAccessor​(RelationshipAccessor accessor)
        INTERNAL: Store relationship accessors for later processing and quick look up.
      • addTable

        public void addTable​(DatabaseTable table)
        INTERNAL:
      • clearMappingAccessors

        public void clearMappingAccessors()
        INTERNAL: This method is called only for canonical model generation during the pre-processing stage. Canonical model generation needs to rebuild its accessor list from one compile round to another within Eclipse. This should not be called otherwise. Anything that is set in the addAccessor(MappingAccessor) method should be cleared here.
      • excludeSuperclassListeners

        public boolean excludeSuperclassListeners()
        INTERNAL:
      • getAlias

        public String getAlias()
        INTERNAL:
      • getClassAccessor

        public ClassAccessor getClassAccessor()
        INTERNAL:
      • getClassDescriptor

        public ClassDescriptor getClassDescriptor()
        INTERNAL: Return the RelationalDescriptor instance associated with this MetadataDescriptor
      • getCMPPolicy

        public CMPPolicy getCMPPolicy()
        INTERNAL:
      • getDefaultAccess

        public String getDefaultAccess()
        INTERNAL:
      • getDefaultCatalog

        public String getDefaultCatalog()
        INTERNAL:
      • getDefaultSchema

        public String getDefaultSchema()
        INTERNAL:
      • getDefaultTableName

        public String getDefaultTableName()
        INTERNAL: The default table name is the descriptor alias, unless this descriptor metadata is an inheritance subclass with a SINGLE_TABLE strategy. Then it is the table name of the root descriptor metadata.
      • getEmbeddedIdAccessor

        public EmbeddedIdAccessor getEmbeddedIdAccessor()
        INTERNAL: Return the embedded id accessor for this descriptor if one exists.
      • getEmbeddedIdAttributeName

        public String getEmbeddedIdAttributeName()
        INTERNAL:
      • getEntityAccessor

        public EntityAccessor getEntityAccessor()
        INTERNAL: This method assumes that by calling this method you are certain that the related class accessor to this descriptor is an EntityAccessor. You should not call this method otherwise, @see getClassAccessor()
      • getField

        public DatabaseField getField​(String fieldName)
        INTERNAL: Return the DatabaseField from the given field name from this descriptor. It also checks primary key fields and parent descriptors.
      • getGenericType

        public String getGenericType​(String genericName)
        INTERNAL: Return the type from the generic name.
      • getGenericTypes

        public Map getGenericTypes()
        INTERNAL:
      • getIdAttributeName

        public String getIdAttributeName()
        INTERNAL: Return the primary key attribute name for this entity.
      • getIdAttributeNames

        public List<String> getIdAttributeNames()
        INTERNAL: Return the id attribute names declared on this descriptor metadata.
      • getIdOrderByAttributeNames

        public List<String> getIdOrderByAttributeNames()
        INTERNAL: Return the primary key attribute names for this entity. If there are no id attribute names set then we are either: 1) an inheritance subclass, get the id attribute names from the root of the inheritance structure. 2) we have an embedded id. Get the id attribute names from the embedded descriptor metadata, which is equal the attribute names of all the direct to field mappings on that descriptor metadata. Currently does not traverse nested embeddables.
      • getBiDirectionalManyToManyAccessor

        public MetadataAccessor getBiDirectionalManyToManyAccessor​(String className,
                                                                   String attributeName)
        INTERNAL: Assumes hasBidirectionalManyToManyAccessorFor has been called before hand.
      • getInheritanceParentDescriptor

        public MetadataDescriptor getInheritanceParentDescriptor()
        INTERNAL: Returns the immediate parent's descriptor in the inheritance hierarchy.
      • getInheritanceRootDescriptor

        public MetadataDescriptor getInheritanceRootDescriptor()
        INTERNAL: Returns the root descriptor of the inheritance hierarchy, that is, the one that defines the inheritance strategy.
      • getJavaClassName

        public String getJavaClassName()
        INTERNAL:
      • getMappingAccessor

        public MappingAccessor getMappingAccessor​(String fieldOrPropertyName)
        INTERNAL: This method will first check for an accessor with name equal to field or property name. If no accessor is found than it assumes the field or property name passed in may be a method name and converts it to its corresponding property name and looks for the accessor again. If still no accessor is found and this descriptor represents an inheritance subclass, then traverse up the chain to look for that accessor. Null is returned otherwise.
      • getMappingAccessor

        protected MappingAccessor getMappingAccessor​(String fieldOrPropertyName,
                                                     boolean checkForMethodName)
        INTERNAL: This method will first check for an accessor with name equal to field or property name. If no accessor is found and the checkForMethodName flag is set to true then we'll attempt to convert a potential method name to its corresponding property name and looks for the accessor again. If still no accessor is found and this descriptor represents an inheritance subclass, then traverse up the chain to look for that accessor. Null is returned otherwise.
      • getMappingAccessors

        public Collection<MappingAccessor> getMappingAccessors()
        INTERNAL: Return the collection of mapping accessors for this descriptor.
      • getMappingForAttributeName

        public DatabaseMapping getMappingForAttributeName​(String attributeName)
        INTERNAL:
      • getMetamodelMappedSuperclassChildDescriptor

        public MetadataDescriptor getMetamodelMappedSuperclassChildDescriptor()
        INTERNAL:
      • getOrderByAttributeNames

        public List<String> getOrderByAttributeNames()
        INTERNAL: This will return the attribute names for all the direct to field mappings on this descriptor metadata. This method will typically be called when an embedded or embedded id attribute has been specified as an order by field
      • getPKClassName

        public String getPKClassName()
        INTERNAL:
      • getPrimaryKeyAccessorForField

        public MappingAccessor getPrimaryKeyAccessorForField​(DatabaseField field)
        INTERNAL: Return the primary key mapping for the given field.
      • getPrimaryKeyField

        public DatabaseField getPrimaryKeyField()
        INTERNAL: Method to return the primary key field name this descriptor metadata. It assumes there is one.
      • getPrimaryKeyFieldName

        public String getPrimaryKeyFieldName()
        INTERNAL: Method to return the primary key field name for this descriptor metadata. It assumes there is one.
      • getPrimaryKeyFields

        public List<DatabaseField> getPrimaryKeyFields()
        INTERNAL Return the primary key fields for this descriptor metadata. If this is an inheritance subclass and it has no primary key fields, then grab the primary key fields from the root. In a table per class inheritance strategy, the primary key fields (and all mappings for that matter) are inherited from the parent meaning there is no need to check the parent in this case, it should have primary key fields and checking the parent could lead to processing errors.
      • getPrimaryKeyJoinColumnAssociation

        public DatabaseField getPrimaryKeyJoinColumnAssociation​(DatabaseField foreignKey)
        INTERNAL: Recursively check the potential chaining of the primary key fields from a inheritance subclass, all the way to the root of the inheritance hierarchy.
      • getPrimaryKeyJoinColumnAssociationField

        public DatabaseField getPrimaryKeyJoinColumnAssociationField​(DatabaseField primaryKeyField)
        INTERNAL: Returns the first primary key join column association if there is one. Otherwise, the primary key field given is returned.
      • getPrimaryKeyTable

        public DatabaseTable getPrimaryKeyTable()
        INTERNAL: Assumes there is one primary key field set. This method should be called when qualifying any primary key field (from a join column) for this descriptor. This method was created because in an inheritance hierarchy with a joined strategy we can't use getPrimaryTableName() since it would return the wrong table name. From the spec, the primary key must be defined on the entity that is the root of the entity hierarchy or on a mapped superclass of the entity hierarchy. The primary key must be defined exactly once in an entity hierarchy.
      • getPrimaryTable

        public DatabaseTable getPrimaryTable()
        INTERNAL:
      • getPrimaryTableName

        public String getPrimaryTableName()
        INTERNAL:
      • getReturningPolicy

        protected ReturningPolicy getReturningPolicy()
        INTERNAL:
      • getSequenceNumberField

        public DatabaseField getSequenceNumberField()
        INTERNAL:
      • getSingleTableMultitenantFields

        public Map<String,​List<DatabaseField>> getSingleTableMultitenantFields()
        INTERNAL: Assumes a call to hasSingleTableMultitenant has been made before hand.
      • hasAdditionalCriteria

        public boolean hasAdditionalCriteria()
        INTERNAL: Returns true is an additional criteria has been set on this descriptor's query manager.
      • hasAssociationOverrideFor

        public boolean hasAssociationOverrideFor​(String attributeName)
        INTERNAL:
      • hasAttributeOverrideFor

        public boolean hasAttributeOverrideFor​(String attributeName)
        INTERNAL:
      • hasCompositePrimaryKey

        public boolean hasCompositePrimaryKey()
        INTERNAL:
      • hasEmbeddedId

        public boolean hasEmbeddedId()
        INTERNAL:
      • hasExistenceChecking

        public boolean hasExistenceChecking()
        INTERNAL:
      • hasBiDirectionalManyToManyAccessorFor

        public boolean hasBiDirectionalManyToManyAccessorFor​(String className,
                                                             String attributeName)
        INTERNAL:
      • hasCache

        public boolean hasCache()
        INTERNAL: Indicates that a Cache annotation or cache element has already been processed for this descriptor.
      • hasCacheable

        public boolean hasCacheable()
        INTERNAL: Indicates that a Cacheable annotation or cache element has already been processed for this descriptor.
      • hasCacheInterceptor

        public boolean hasCacheInterceptor()
        INTERNAL: Indicates that a CacheInterceptor annotation or cacheInterceptor element has already been processed for this descriptor.
      • hasDefaultRedirectors

        public boolean hasDefaultRedirectors()
        INTERNAL: Indicates that a DefaultRedirectors annotation or default-redirectors element has already been processed for this descriptor.
      • hasChangeTracking

        public boolean hasChangeTracking()
        INTERNAL: Indicates that a Change tracking annotation or change tracking element has already been processed for this descriptor.
      • hasCopyPolicy

        public boolean hasCopyPolicy()
        INTERNAL: Indicates that a copy Policy annotation or copy policy element has already been processed for this descriptor.
      • hasConverts

        public boolean hasConverts​(String attributeName)
        INTERNAL: Return true if there is convert metadata for the given attribute name.
      • hasCustomizer

        public boolean hasCustomizer()
        INTERNAL: Indicates that a customizer annotation or customizer element has already been processed for this descriptor.
      • hasIdAccessor

        public boolean hasIdAccessor()
        INTERNAL: Return whether there is an IdAccessor on this descriptor.
      • hasMapKeyConverts

        public boolean hasMapKeyConverts​(String attributeName)
        INTERNAL: Return true if there is map key convert metadata for the given attribute name.
      • hasMappingAccessor

        public boolean hasMappingAccessor​(String attributeName)
        INTERNAL: Returns true if we already have (processed) an accessor for the given attribute name.
      • hasMappingForAttributeName

        public boolean hasMappingForAttributeName​(String attributeName)
        INTERNAL:
      • hasMultitenant

        public boolean hasMultitenant()
        INTERNAL: Indicates if multitenant metadata has been processed for this descriptor.
      • hasPKClass

        public boolean hasPKClass()
        INTERNAL:
      • hasPrimaryKey

        public boolean hasPrimaryKey()
        INTERNAL: Indicates that a PrimaryKey annotation or primary-key element has been processed for this descriptor.
      • hasPrimaryKeyFields

        public boolean hasPrimaryKeyFields()
        INTERNAL: Return true is the descriptor has primary key fields set.
      • hasReadOnly

        public boolean hasReadOnly()
        INTERNAL: Indicates that a read only annotation or read only element has already been processed for this descriptor.
      • hasSingleTableMultitenant

        public boolean hasSingleTableMultitenant()
        INTERNAL: Indicates if single table multitenant metadata has been processed for this descriptor.
      • m_hasSerializedObjectPolicy

        public boolean m_hasSerializedObjectPolicy()
        INTERNAL: Indicates that a SerializedObject annotation or serialized-object element has been processed for this descriptor.
      • isCacheableTrue

        public boolean isCacheableTrue()
        INTERNAL: Indicates that an explicit cacheable value of true has been set for this descriptor.
      • isCacheableFalse

        public boolean isCacheableFalse()
        INTERNAL: Indicates that an explicit cacheable value of false has been set for this descriptor.
      • isCascadePersist

        public boolean isCascadePersist()
        INTERNAL: Indicates that cascade-persist should be applied to all relationship mappings for this entity.
      • isEmbeddable

        public boolean isEmbeddable()
        INTERNAL:
      • isEmbeddableCollection

        public boolean isEmbeddableCollection()
        INTERNAL:
      • isInheritanceSubclass

        public boolean isInheritanceSubclass()
        INTERNAL:
      • isMappedSuperclass

        public boolean isMappedSuperclass()
        INTERNAL: Return whether the ClassAccessor on this MetadataDescriptor is a MappedSuperclassAccessor.
        Since:
        EclipseLink 1.2 for the JPA 2.0 Reference Implementation
      • pkClassWasNotValidated

        public boolean pkClassWasNotValidated()
        INTERNAL:
      • processMappingAccessors

        public void 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.
      • removePrimaryKeyField

        public void removePrimaryKeyField​(DatabaseField field)
        INTERNAL: Remove the following field from the primary key field lists. Presumably, it is not a primary key field or is being replaced with another. See EmbeddedAccessor processAttributeOverride method.
      • setAccessTypeOnClassDescriptor

        public void setAccessTypeOnClassDescriptor​(String accessType)
        INTERNAL: Record whether this descriptor uses property access. This information is used to modify the behavior of some of our weaving features
      • setAlias

        public void setAlias​(String alias)
        INTERNAL:
      • getCacheable

        public Boolean getCacheable()
        INTERNAL: Get entity @Cacheable annotation value.
        Returns:
        Entity @Cacheable annotation value. This value refers to current class only and does not contain inherited value from parent classes.
      • setCacheable

        public void setCacheable​(Boolean cacheable)
        INTERNAL: Set entity @Cacheable annotation value.
        Parameters:
        cacheable - Entity @Cacheable annotation value. This value refers to current class only and does not contain inherited value from parent classes.
      • setCacheableInDescriptor

        public void setCacheableInDescriptor()
        INTERNAL: Pass entity @Cacheable annotation value to cache configuration object in class descriptor.
      • setClassAccessor

        public void setClassAccessor​(ClassAccessor accessor)
        INTERNAL:
      • setDefaultAccess

        public void setDefaultAccess​(String defaultAccess)
        INTERNAL:
      • setDefaultAccessMethods

        public void setDefaultAccessMethods​(AccessMethodsMetadata accessMethods)
        INTERNAL: Default access methods can come from the following locations (in XML only) : - persistence-unit-defaults - entity-mappings - entity - embeddable Be default, the default access methods are set to use "get" and "set" unless they are overridden by discovering access methods specified at one of the locations above.
      • setDefaultCatalog

        public void setDefaultCatalog​(String defaultCatalog)
        INTERNAL:
      • setDefaultSchema

        public void setDefaultSchema​(String defaultSchema)
        INTERNAL:
      • setDescriptor

        public void setDescriptor​(ClassDescriptor descriptor)
        INTERNAL: Set the RelationalDescriptor instance associated with this MetadataDescriptor
      • setEmbeddedIdAccessor

        public void setEmbeddedIdAccessor​(EmbeddedIdAccessor embeddedIdAccessor)
        INTERNAL:
      • setEntityEventListener

        public void setEntityEventListener​(EntityListener listener)
        INTERNAL:
      • setExcludeDefaultListeners

        public void setExcludeDefaultListeners​(boolean excludeDefaultListeners)
        INTERNAL:
      • setExcludeSuperclassListeners

        public void setExcludeSuperclassListeners​(boolean excludeSuperclassListeners)
        INTERNAL:
      • setExistenceChecking

        public void setExistenceChecking​(String existenceChecking)
        INTERNAL:
      • setHasCache

        public void setHasCache()
        INTERNAL: Indicates that we have processed a cache annotation or cache xml element.
      • setHasCacheInterceptor

        public void setHasCacheInterceptor()
        INTERNAL: Indicates that we have processed a cache annotation or cache xml element.
      • setHasCustomizer

        public void setHasCustomizer()
        INTERNAL: Indicates that we have processed a customizer annotation or customizer xml element.
      • setHasDefaultRedirectors

        public void setHasDefaultRedirectors()
        INTERNAL: Indicates that we have processed a cache annotation or cache xml element.
      • setHasPrimaryKey

        public void setHasPrimaryKey()
        INTERNAL: Indicates that we have processed a PrimaryKey annotation or primary-key xml element.
      • setHasChangeTracking

        public void setHasChangeTracking()
        INTERNAL: Indicates that we have processed a change tracking annotation or change tracking xml element.
      • setHasCopyPolicy

        public void setHasCopyPolicy()
        INTERNAL: Indicates that we have processed a copy policy annotation or copy policy xml element.
      • setHasSerializedObjectPolicy

        public void setHasSerializedObjectPolicy()
        INTERNAL: Indicates that we have processed a serialized object annotation or serialized object xml element.
      • setInheritanceParentDescriptor

        public void setInheritanceParentDescriptor​(MetadataDescriptor inheritanceParentDescriptor)
        INTERNAL: Set the immediate parent's descriptor of the inheritance hierarchy.
      • setInheritanceRootDescriptor

        public void setInheritanceRootDescriptor​(MetadataDescriptor inheritanceRootDescriptor)
        INTERNAL: Set the root descriptor of the inheritance hierarchy, that is, the one that defines the inheritance strategy.
      • setIsCascadePersist

        public void setIsCascadePersist​(boolean isCascadePersist)
        INTERNAL: Indicates that cascade-persist should be added to the set of cascade values for all relationship mappings.
      • setIsEmbeddable

        public void setIsEmbeddable()
        INTERNAL:
      • setJavaClass

        public void setJavaClass​(MetadataClass javaClass)
        INTERNAL: Used to set this descriptors java class.
      • setMetamodelMappedSuperclassChildDescriptor

        public void setMetamodelMappedSuperclassChildDescriptor​(MetadataDescriptor childDescriptor)
        INTERNAL:
      • setOptimisticLockingPolicy

        public void setOptimisticLockingPolicy​(OptimisticLockingPolicy policy)
        INTERNAL:
      • setPKClass

        public void setPKClass​(MetadataClass pkClass)
        INTERNAL:
      • setPrimaryTable

        public void setPrimaryTable​(DatabaseTable primaryTable)
        INTERNAL:
      • setReadOnly

        public void setReadOnly​(boolean readOnly)
        INTERNAL:
      • setSequenceNumberField

        public void setSequenceNumberField​(DatabaseField field)
        INTERNAL:
      • setSequenceNumberName

        public void setSequenceNumberName​(String name)
        INTERNAL:
      • setUsesCascadedOptimisticLocking

        public void setUsesCascadedOptimisticLocking​(Boolean usesCascadedOptimisticLocking)
        INTERNAL:
      • useNoCache

        public void useNoCache()
        INTERNAL:
      • usesCascadedOptimisticLocking

        public boolean usesCascadedOptimisticLocking()
        INTERNAL:
      • usesDefaultPropertyAccess

        public boolean usesDefaultPropertyAccess()
        INTERNAL: Returns true if this class uses default property access. All access discovery and processing should have been performed before calling this method and a default access type should have been set.
      • usesOptimisticLocking

        public boolean usesOptimisticLocking()
        INTERNAL:
      • usesSingleTableInheritanceStrategy

        public boolean usesSingleTableInheritanceStrategy()
        INTERNAL: Indicates if the strategy on the descriptor's inheritance policy is SINGLE_TABLE. This method must only be called on those descriptors holding an EntityAccessor. NOTE: Inheritance is currently not supported on embeddables.
      • usesTablePerClassInheritanceStrategy

        public boolean usesTablePerClassInheritanceStrategy()
        INTERNAL: Return true if this descriptor uses a table per class inheritance policy.
      • usesVersionColumnOptimisticLocking

        public boolean usesVersionColumnOptimisticLocking()
        INTERNAL: Return true if this descriptors class processed OptimisticLocking meta data of type VERSION_COLUMN.
      • validateDerivedPKClassId

        public void validateDerivedPKClassId​(String attributeName,
                                             String expectedType,
                                             String referenceClassName)
        INTERNAL: This method is used to validate derived id fields only. Re-using the invalid composite pk attribute validation exception would yield an interesting error message. Therefore, this method should be used to validate derived id members. When validating derived ids things are slightly reversed in terms on context. The expectedType passed in should be the boxed type (were applicable).
      • validatePKClassId

        public void validatePKClassId​(String attributeName,
                                      String actualType)
        INTERNAL: This method is used only to validate id fields that were found on a pk class were also found on the entity. The actualType passed in should be the boxed type (were applicable).