java.lang.Object
org.eclipse.persistence.internal.jpa.metadata.MetadataProject

public class MetadataProject extends Object
INTERNAL: A MetadataProject stores metadata and also helps to facilitate the metadata processing. Key notes: - Care should be taken when using Sets to hold metadata and checking their equality. In most cases you should be able to us a List or Map since most additions to those lists should not occur multiple times for the same object. Just be aware of what you are gathering and how. For example, for ClassAccessors, they can always be stored in a map keyed on accessor.getJavaClassName(). List of mapping accessors is ok as well since in most cases we check isProcessed() before calling process on them etc. - methods should be preserved in alphabetical order.
Since:
TopLink EJB 3.0 Reference Implementation
  • Field Details

  • Constructor Details

    • MetadataProject

      public MetadataProject(PersistenceUnitInfo puInfo, AbstractSession session, boolean weaveLazy, boolean weaveEager, boolean weaveFetchGroups, boolean multitenantSharedEmf, boolean multitenantSharedCache)
      INTERNAL: Create and return a new MetadataProject with puInfo as its PersistenceUnitInfo, session as its Session and weavingEnabled as its global dynamic weaving state.
      Parameters:
      puInfo - - the PersistenceUnitInfo
      session - - the Session
  • Method Details

    • addAccessor

      protected void addAccessor(ClassAccessor accessor)
      INTERNAL: This method will add the descriptor to the actual EclipseLink project, if it has not already been added. This method if called for entities and embeddable classes (which are both weavable classes).
    • addAccessorWithCustomizer

      public void addAccessorWithCustomizer(ClassAccessor accessor)
      INTERNAL:
    • addAccessorWithDerivedId

      public void addAccessorWithDerivedId(ClassAccessor accessor)
      INTERNAL:
    • addAlias

      public void addAlias(String alias, MetadataDescriptor descriptor)
      INTERNAL:
    • addConverter

      public void addConverter(AbstractConverterMetadata converter)
      INTERNAL: Add a abstract converter metadata to the project. The actual processing isn't done until an accessor referencing the converter is processed.
    • addConverterAccessor

      public void addConverterAccessor(ConverterAccessor converterAccessor)
      INTERNAL: Add a abstract converter metadata to the project. The actual processing isn't done until an accessor referencing the converter is processed.
    • addDefaultListener

      public void addDefaultListener(EntityListenerMetadata defaultListener)
      INTERNAL:
    • addDirectCollectionAccessor

      public void addDirectCollectionAccessor(MappingAccessor accessor)
      INTERNAL: Store basic collection accessors for later processing and quick look up.
    • addEmbeddableAccessor

      public void addEmbeddableAccessor(EmbeddableAccessor accessor)
      INTERNAL: Add an embeddable accessor to this project. Assumes the embeddable needs to be added. That is, does not check if it already exists and cause a merge. The caller is responsible for that.
    • addEmbeddableMappingAccessor

      public void addEmbeddableMappingAccessor(MappingAccessor accessor)
      INTERNAL:
    • addEntityAccessor

      public void addEntityAccessor(EntityAccessor accessor)
      INTERNAL: Add an entity accessor to this project. Assumes the entity needs to be added. That is, does not check if it already exists and cause a merge. The caller is responsible for that.
    • addEntityGraph

      public void addEntityGraph(AttributeGroup entityGraph)
      INTERNAL: Add the given entity graph (internal attribute group).
    • addEntityMappings

      public void addEntityMappings(XMLEntityMappings entityMappings)
      INTERNAL: The avoid processing the same mapping file twice (e.g. user may explicitly specify the orm.xml file) we store the list of entity mappings in a map keyed on their URL.
    • addGeneratedValue

      public void addGeneratedValue(GeneratedValueMetadata generatedvalue, MetadataClass entityClass)
      INTERNAL:
    • addIdClass

      public void addIdClass(String idClassName)
      INTERNAL: Add EmbeddedId and IdClass ids to the project
    • addInterfaceAccessor

      public void addInterfaceAccessor(InterfaceAccessor accessor)
      INTERNAL: Add a InterfaceAccessor to this project.
    • addMappedSuperclass

      public void addMappedSuperclass(MappedSuperclassAccessor mappedSuperclass)
      INTERNAL: Add a mapped superclass accessor to this project. Assumes the mapped superclass needs to be added. That is, does not check if it already exists and cause a merge. The caller is responsible for that. At runtime, this map will contain mapped superclasses from XML only. The canonical model processor will populate all mapped superclasses in this map.
    • addMetamodelMappedSuperclass

      public void addMetamodelMappedSuperclass(MappedSuperclassAccessor accessor, MetadataDescriptor childDescriptor)
      INTERNAL: The metamodel API requires that descriptors exist for mappedSuperclasses in order to obtain their mappings.

      In order to accomplish this, this method that is called from EntityAccessor will ensure that the descriptors on all mappedSuperclass accessors are setup so that they can be specially processed later in MetadataProject.processStage2() - where the m_mappedSuperclassAccessors Map is required.

      We do not use the non-persisting MAPPED_SUPERCLASS_RESERVED_PK_NAME PK field. Normally when the MappedSuperclass is part of an inheritance hierarchy of the form MS->MS->E, where there is an PK Id on the root Entity E, we need to add the MAPPED_SUPERCLASS_RESERVED_PK_NAME PK field solely for metadata processing to complete. Why? because even though we treat MappedSuperclass objects as a RelationalDescriptor - we only persist RelationalDescriptor objects that relate to concrete Entities.

      This method is referenced by EntityAccessor.addPotentialMappedSuperclass() during an initial predeploy() and later during a deploy()

      Parameters:
      accessor - - The mappedSuperclass accessor for the field on the mappedSuperclass
      Since:
      EclipseLink 1.2 for the JPA 2.0 Reference Implementation
    • addPartitioningPolicy

      public void addPartitioningPolicy(AbstractPartitioningMetadata policy)
      INTERNAL: Add the partitioning policy by name.
    • addComplexMetadataType

      public void addComplexMetadataType(ComplexTypeMetadata type)
      INTERNAL: Add the named PLSQL or Oracle complex metadata type.
    • addQuery

      public void addQuery(NamedQueryMetadata query)
      INTERNAL: Add a query to the project overriding where necessary.
    • addRelationshipAccessor

      public void addRelationshipAccessor(RelationshipAccessor accessor)
      INTERNAL:
    • addRootEmbeddableAccessor

      public void addRootEmbeddableAccessor(EmbeddableAccessor accessor)
      INTERNAL: Add a root level embeddable accessor.
    • addSequenceGenerator

      public void addSequenceGenerator(SequenceGeneratorMetadata sequenceGenerator, String defaultCatalog, String defaultSchema)
      INTERNAL: Add a sequence generator metadata to the project. The actual processing isn't done till processSequencing is called.
    • addUuidGenerator

      public void addUuidGenerator(UuidGeneratorMetadata uuidGenerator)
      INTERNAL: Add a UUID generator metadata to the project. The actual processing isn't done till processSequencing is called.
    • addSQLResultSetMapping

      public void addSQLResultSetMapping(SQLResultSetMappingMetadata sqlResultSetMapping)
      INTERNAL: Add an sql results set mapping to the project overriding where necessary.
    • addStaticMetamodelClass

      public void addStaticMetamodelClass(MetadataAnnotation annotation, MetadataClass metamodelClass)
      INTERNAL: Add a discovered metamodel class to the session.
    • addTableGenerator

      public void addTableGenerator(TableGeneratorMetadata tableGenerator, String defaultCatalog, String defaultSchema)
      INTERNAL: Add a table generator metadata to the project. The actual processing isn't done till processSequencing is called.
    • addVirtualClass

      public void addVirtualClass(ClassAccessor accessor)
      INTERNAL: Add virtual class accessor to the project. A virtual class is one that has VIRTUAL access and the class does not exist on the classpath.
    • createDynamicClass

      protected void createDynamicClass(MetadataDescriptor descriptor, Map<String,MetadataDescriptor> virtualEntities, DynamicClassLoader dcl)
      INTERNAL: Create the dynamic class using JPA metadata processed descriptors. Called at deploy time after all metadata processing has completed.
    • createDynamicClasses

      public void createDynamicClasses(ClassLoader loader)
      INTERNAL: Create the dynamic class using JPA metadata processed descriptors. Called at deploy time after all metadata processing has completed.
    • createDynamicType

      protected void createDynamicType(MetadataDescriptor descriptor, Map<String,DynamicType> dynamicTypes, DynamicClassLoader dcl)
      INTERNAL: Create the dynamic types using JPA metadata processed descriptors. Called at deploy time after all metadata processing has completed.
    • disableWeaving

      public void disableWeaving()
      INTERNAL: Set if the project should use indirection for lazy relationships.
    • excludeDefaultMappings

      public boolean excludeDefaultMappings()
      INTERNAL: Return true if an exclude-default-mappings setting have been set for this persistence unit.
    • getAccessor

      public ClassAccessor getAccessor(String className)
      INTERNAL: Return the accessor for the given class. Could be an entity or an embeddable. Note: It may return null.
    • getAccessorsWithCustomizer

      public List<ClassAccessor> getAccessorsWithCustomizer()
      INTERNAL:
    • getAllAccessors

      public Collection<ClassAccessor> getAllAccessors()
      INTERNAL:
    • getAutoApplyConverter

      public ConverterAccessor getAutoApplyConverter(MetadataClass cls)
      Return the converter for the auto apply class type.
    • getCompositeProcessor

      public MetadataProcessor getCompositeProcessor()
      INTERNAL:
    • getConverter

      public AbstractConverterMetadata getConverter(String name)
      INTERNAL:
    • getConverterAccessor

      public ConverterAccessor getConverterAccessor(MetadataClass cls)
      INTERNAL:
    • getConverterAccessors

      public Map<String,ConverterAccessor> getConverterAccessors()
      INTERNAL:
    • getDefaultListeners

      public Set<EntityListenerMetadata> getDefaultListeners()
      INTERNAL:
    • getEmbeddableAccessor

      public EmbeddableAccessor getEmbeddableAccessor(MetadataClass cls)
      INTERNAL: This method will attempt to look up the embeddable accessor for the reference class provided. If no accessor is found, null is returned.
    • getEmbeddableAccessor

      public EmbeddableAccessor getEmbeddableAccessor(MetadataClass cls, boolean checkIsIdClass)
      INTERNAL: This method will attempt to look up the embeddable accessor for the reference class provided. If no accessor is found, null is returned.
    • getEmbeddableAccessor

      public EmbeddableAccessor getEmbeddableAccessor(String className)
      INTERNAL: Return the embeddable accessor with the given classname.
    • getEmbeddableAccessors

      public Collection<EmbeddableAccessor> getEmbeddableAccessors()
      INTERNAL: Return the embeddable accessor with the given classname.
    • getEntityAccessor

      public EntityAccessor getEntityAccessor(MetadataClass cls)
      INTERNAL: Return the entity accessor for the given class name.
    • getEntityAccessor

      public EntityAccessor getEntityAccessor(String className)
      INTERNAL: Return the entity accessor for the given class name.
    • getEntityAccessors

      public Collection<EntityAccessor> getEntityAccessors()
      INTERNAL:
    • getEntityMappings

      public Collection<XMLEntityMappings> getEntityMappings()
      INTERNAL:
    • getInterfaceAccessor

      public InterfaceAccessor getInterfaceAccessor(String className)
      INTERNAL: Return the entity accessor for the given class.
    • getLogger

      public MetadataLogger getLogger()
      INTERNAL: Return the logger used by the processor.
    • getMappedSuperclassAccessor

      public MappedSuperclassAccessor getMappedSuperclassAccessor(MetadataClass cls)
      INTERNAL:
    • getMappedSuperclassAccessor

      public MappedSuperclassAccessor getMappedSuperclassAccessor(String className)
      INTERNAL:
    • getMappedSuperclasses

      public Collection<MappedSuperclassAccessor> getMappedSuperclasses()
      INTERNAL:
    • getMetamodelMappedSuperclasses

      public Collection<MappedSuperclassAccessor> getMetamodelMappedSuperclasses()
      INTERNAL: Returns the collection of metamodel MappedSuperclassAccessors. This collection is NOT and should NOT be used for any deployment descriptor metadata processing. It is used solely with the metamodel.
      Since:
      EclipseLink 1.2 for the JPA 2.0 Reference Implementation
      See Also:
    • getPartitioningPolicy

      public AbstractPartitioningMetadata getPartitioningPolicy(String name)
      INTERNAL: Return the named partitioning policy.
    • getPersistenceUnitDefaultCatalog

      protected String getPersistenceUnitDefaultCatalog()
      INTERNAL: Return the persistence unit default catalog.
    • getPersistenceUnitDefaultSchema

      protected String getPersistenceUnitDefaultSchema()
      INTERNAL: Return the persistence unit default schema.
    • getPersistenceUnitInfo

      public PersistenceUnitInfo getPersistenceUnitInfo()
      INTERNAL:
    • getPersistenceUnitMetadata

      public XMLPersistenceUnitMetadata getPersistenceUnitMetadata()
      INTERNAL:
    • getComplexTypeMetadata

      public ComplexTypeMetadata getComplexTypeMetadata(String name)
      INTERNAL: Return the named PLSQL or Oracle complex metadata type.
    • getProject

      public Project getProject()
      INTERNAL: Return the core API Project associated with this MetadataProject.
      Since:
      EclipseLink 1.2 for the JPA 2.0 Reference Implementation
    • getRootEmbeddableAccessors

      public Collection<EmbeddableAccessor> getRootEmbeddableAccessors()
      INTERNAL: Add a root level embeddable accessor. Nested embeddables will be pre-processed from their roots down.
      See Also:
    • getSession

      public AbstractSession getSession()
      INTERNAL:
    • getSharedCacheModeName

      protected String getSharedCacheModeName()
      INTERNAL: This method will return the name of the SharedCacheMode if specified in the persistence.xml file. Note, this is a JPA 2.0 feature, therefore, this method needs to catch any exception as a result of trying to access this information from a JPA 1.0 container.
    • setSharedCacheMode

      public void setSharedCacheMode(SharedCacheMode m_sharedCacheMode)
      INTERNAL: Sets the SharedCacheMode value.
    • getShouldForceFieldNamesToUpperCase

      public boolean getShouldForceFieldNamesToUpperCase()
      INTERNAL: Used to uppercase default and user defined column field names
    • getStructConverters

      public List<StructConverterMetadata> getStructConverters()
      INTERNAL:
    • getWeavableClassNames

      public Collection<String> getWeavableClassNames()
      INTERNAL: Returns all those classes in this project that are available for weaving. This list currently includes entity, embeddables and mappedsuperclass with no children classes.
    • hasAutoApplyConverter

      public boolean hasAutoApplyConverter(MetadataClass cls)
      Return true if there is an auto-apply converter for the given cls.
    • hasConverter

      public boolean hasConverter(String name)
      INTERNAL:
    • hasConverterAccessor

      public boolean hasConverterAccessor(MetadataClass cls)
      INTERNAL:
    • hasEmbeddable

      public boolean hasEmbeddable(MetadataClass cls)
      INTERNAL:
    • hasEmbeddable

      public boolean hasEmbeddable(String className)
      INTERNAL:
    • hasEntity

      public boolean hasEntity(MetadataClass cls)
      INTERNAL:
    • hasEntity

      public boolean hasEntity(String className)
      INTERNAL:
    • hasEntityGraph

      public boolean hasEntityGraph(String name)
      INTERNAL: Return true is there exist and entity graph already for the given name.
    • hasEntityThatImplementsInterface

      public boolean hasEntityThatImplementsInterface(String interfaceName)
      INTERNAL:
    • hasInterface

      public boolean hasInterface(MetadataClass cls)
      INTERNAL:
    • hasMappedSuperclass

      public boolean hasMappedSuperclass(MetadataClass cls)
      INTERNAL:
    • hasMappedSuperclass

      public boolean hasMappedSuperclass(String className)
      INTERNAL:
    • hasSharedCacheMode

      public boolean hasSharedCacheMode()
      INTERNAL:
    • isIdClass

      public boolean isIdClass(MetadataClass idClass)
      INTERNAL:
    • isSharedCacheModeAll

      public boolean isSharedCacheModeAll()
      INTERNAL: Return true if the caching has been specified as ALL in the persistence.xml.
    • isSharedCacheModeDisableSelective

      public boolean isSharedCacheModeDisableSelective()
      INTERNAL: Return true if the caching has been specified as DISABLE_SELECTIVE in the persistence.xml. DISABLE_SELECTIVE is the default therefore this will also return true if no caching setting was set.
    • isSharedCacheModeEnableSelective

      public boolean isSharedCacheModeEnableSelective()
      INTERNAL: Return true if the caching has been specified as ENABLE_SELECTIVE in the persistence.xml.
    • isSharedCacheModeNone

      public boolean isSharedCacheModeNone()
      INTERNAL: Return true if the caching has been specified as NONE in the persistence.xml.
    • isSharedCacheModeUnspecified

      public boolean isSharedCacheModeUnspecified()
      INTERNAL: Return true if the caching has been specified as UNSPECIFIED in the persistence.xml.
    • isWeavingEagerEnabled

      public boolean isWeavingEagerEnabled()
      INTERNAL: Return if the project should use indirection for eager relationships.
    • isWeavingFetchGroupsEnabled

      public boolean isWeavingFetchGroupsEnabled()
      INTERNAL: Return if the project should process fetch groups.
    • isWeavingLazyEnabled

      public boolean isWeavingLazyEnabled()
      INTERNAL: Return if the project should use indirection for lazy relationships.
    • isXMLMappingMetadataComplete

      public boolean isXMLMappingMetadataComplete()
      INTERNAL: Return true if an xml-mapping-metadata-complete setting has been set for this persistence unit.
    • processEmbeddableMappingAccessors

      protected void processEmbeddableMappingAccessors()
      INTERNAL: Process the embeddable mapping accessors.
    • processAccessorsWithDerivedIDs

      protected void processAccessorsWithDerivedIDs()
      INTERNAL: Process descriptors with IDs derived from relationships. This will also complete unfinished validation as well as secondary table processing on entity accessors. This method will fast track some relationship mappings which is ok since simple primary keys will already have been discovered and processed whereas any derived id's and their fast tracking to be processed will be handled now.
    • processDirectCollectionAccessors

      public void processDirectCollectionAccessors()
      INTERNAL: Process any BasicCollection annotation and/or BasicMap annotation that were found. They are not processed till after an id has been processed since they rely on one to map the collection table.
    • processInterfaceAccessors

      protected void processInterfaceAccessors()
      INTERNAL: This method 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.
    • processNonOwningRelationshipAccessors

      protected void processNonOwningRelationshipAccessors()
      INTERNAL: Process the non-owning relationship accessors. All owning relationshuip accessors should be processed. Some non-owning relationships may have already been fast tracked to from an element collection containing an embeddable (with a non-owning relationship).
    • processOwningRelationshipAccessors

      protected void processOwningRelationshipAccessors()
      INTERNAL: Process the owning relationship accessors. Some may have already been processed through the processing of derived id's therefore don't process them again.
    • processPersistenceUnitMetadata

      protected void processPersistenceUnitMetadata(MetadataDescriptor descriptor)
      INTERNAL: Process any and all persistence unit metadata and defaults to the given descriptor. This method for will called for every descriptor belonging to this project/persistence unit.
    • processQueries

      public void processQueries()
      INTERNAL: Process the named native queries we found and add them to the given session.
    • processSequencingAccessors

      protected void processSequencingAccessors()
      INTERNAL: Process the sequencing information. At this point, through validation, it is not possible to have: 1 - a table generator with the generator name equal to DEFAULT_SEQUENCE_GENERATOR or DEFAULT_IDENTITY_GENERATOR 2 - a sequence generator with the name eqaul to DEFAULT_TABLE_GENERATOR or DEFAULT_IDENTITY_GENERATOR 3 - you can't have both a sequence generator and a table generator with the same DEFAULT_AUTO_GENERATOR name.
      See Also:
    • processPartitioning

      protected void processPartitioning()
      Process the partitioning metedata and add the PartitioningPolicys to the project.
    • processStage1

      public void processStage1()
      INTERNAL: Stage 1 processing is a pre-processing stage that will perform the following tasks: - gather a list of mapping accessors for all entities and embeddables. - discover all global converter specifications. - discover mapped superclasses and inheritance parents. NOTE: This method should only perform any preparatory work like, class discovery, flag settings etc. Hard processing will begin in stage 2.
      See Also:
    • processStage2

      public void processStage2()
      INTERNAL: Stage 2 processing will perform the following tasks: - process all direct mapping accessors from entities, embeddables and mapped superclasses. - gather a list of relationship accessors and any other special interest accessors to be processed in stage 3.
      See Also:
    • processStage3

      public void processStage3(PersistenceUnitProcessor.Mode mode)
      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.
    • processTable

      public void processTable(TableMetadata table, String defaultName, String defaultCatalog, String defaultSchema, ORMetadata owner)
      INTERNAL: Common table processing for table, secondary table, join table, collection table and table generators
    • removeEmbeddableAccessor

      public void removeEmbeddableAccessor(MetadataClass metadataClass)
      INTERNAL: Used from the canonical model generator. Specifically when the user removes the embeddable designation or changes the embeddable to either a mapped superclass or entity.
    • removeEntityAccessor

      public void removeEntityAccessor(MetadataClass metadataClass)
      INTERNAL: Used from the canonical model generator. Specifically when the user removes the entity designation or changes the entity to either a mapped superclass or embeddable.
    • removeMappedSuperclassAccessor

      public void removeMappedSuperclassAccessor(MetadataClass metadataClass)
      INTERNAL: Used from the canonical model generator. Specifically when the user removes the mapped superclass designation or changes the mapped superclass to either an entity or embeddable.
    • setAllowNativeSQLQueries

      public void setAllowNativeSQLQueries(boolean allowNativeSQLQueries)
      INTERNAL: When at least one entity is found that is multitenant, we turn off native SQL queries.
    • setCompositeProcessor

      public void setCompositeProcessor(MetadataProcessor compositeProcessor)
      INTERNAL: set compositeProcessor that owns this and pear MetadataProcessors used to create composite persistence unit.
    • setPersistenceUnitMetadata

      public void setPersistenceUnitMetadata(XMLPersistenceUnitMetadata persistenceUnitMetadata)
      INTERNAL:
    • setShouldForceFieldNamesToUpperCase

      public void setShouldForceFieldNamesToUpperCase(boolean shouldForceFieldNamesToUpperCase)
      INTERNAL: Used to uppercase default and user defined column field names
    • toString

      public String toString()
      INTERNAL:
      Overrides:
      toString in class Object
    • useDelimitedIdentifier

      public boolean useDelimitedIdentifier()
      INTERNAL:
    • usesMultitenantSharedCache

      public boolean usesMultitenantSharedCache()
      INTERNAL: Return true if the entity manager factory cache for this project is intended to be shared amongst multitenants.
    • usesMultitenantSharedEmf

      public boolean usesMultitenantSharedEmf()
      INTERNAL: Return true if the entity manager factory for this project is intended to be shared amongst multitenants.
    • hasVirtualClasses

      public boolean hasVirtualClasses()
      INTERNAL: Return true if the entity manager factory for this project has any virtual classes