Class MetamodelImpl

  • All Implemented Interfaces:
    jakarta.persistence.metamodel.Metamodel, Serializable

    public class MetamodelImpl
    extends Object
    implements jakarta.persistence.metamodel.Metamodel, Serializable

    Purpose: Provides the implementation for the Metamodel interface of the JPA 2.0 Metamodel API (part of the JSR-317 EJB 3.1 Criteria API)

    Description: Provides access to the metamodel of persistent Entities, MappedSuperclasses, Embeddables, ManagedTypes and Types in the persistence unit. Note: Since the types Map is lazy-loaded with key:value pairs - the designer and especially the user must realized that a particular BasicType may not be in the Map until it is referenced.

    Since:
    EclipseLink 1.2 - JPA 2.0
    See Also:
    Metamodel, Serialized Form
    • Field Detail

      • DEFAULT_ELEMENT_TYPE_FOR_UNSUPPORTED_MAPPINGS

        public static final Class DEFAULT_ELEMENT_TYPE_FOR_UNSUPPORTED_MAPPINGS
        Default elementType Class when we the type cannot be determined for unsupported mappings such as Transformation and VariableOneToOne
    • Constructor Detail

      • MetamodelImpl

        public MetamodelImpl​(jakarta.persistence.EntityManager em)
      • MetamodelImpl

        public MetamodelImpl​(jakarta.persistence.EntityManagerFactory emf)
      • MetamodelImpl

        public MetamodelImpl​(EntityManagerSetupImpl emSetupImpl)
        INTERNAL:
        Parameters:
        emSetupImpl -
    • Method Detail

      • embeddable

        public <X> jakarta.persistence.metamodel.EmbeddableType<X> embeddable​(Class<X> clazz)
        Return the metamodel embeddable type representing the embeddable class.
        Specified by:
        embeddable in interface jakarta.persistence.metamodel.Metamodel
        Parameters:
        clazz - the type of the represented embeddable class
        Returns:
        the metamodel embeddable type
        Throws:
        IllegalArgumentException - if not an embeddable class
      • entity

        public <X> jakarta.persistence.metamodel.EntityType<X> entity​(Class<X> clazz)
        Return the metamodel entity type representing the entity.
        Specified by:
        entity in interface jakarta.persistence.metamodel.Metamodel
        Parameters:
        clazz - the type of the represented entity
        Returns:
        the metamodel entity type
        Throws:
        IllegalArgumentException - if not an entity
      • getAllManagedTypeAttributes

        public List<jakarta.persistence.metamodel.Attribute> getAllManagedTypeAttributes()
        INTERNAL: Return a List of all attributes for all ManagedTypes.
        Returns:
      • getEmbeddables

        public Set<jakarta.persistence.metamodel.EmbeddableType<?>> getEmbeddables()
        Return the metamodel embeddable types.
        Specified by:
        getEmbeddables in interface jakarta.persistence.metamodel.Metamodel
        Returns:
        the metamodel embeddable types
      • getEntities

        public Set<jakarta.persistence.metamodel.EntityType<?>> getEntities()
        Return the metamodel entity types.
        Specified by:
        getEntities in interface jakarta.persistence.metamodel.Metamodel
        Returns:
        the metamodel entity types
      • getManagedTypesMap

        public Map<String,​ManagedTypeImpl<?>> getManagedTypesMap()
        Return the metamodel managed types map.
      • getManagedTypes

        public Set<jakarta.persistence.metamodel.ManagedType<?>> getManagedTypes()
        Return the metamodel managed types.
        Specified by:
        getManagedTypes in interface jakarta.persistence.metamodel.Metamodel
        Returns:
        the metamodel managed types
      • getMappedSuperclasses

        public Set<MappedSuperclassTypeImpl<?>> getMappedSuperclasses()
        INTERNAL: Return the Set of MappedSuperclassType objects
        Returns:
      • getProject

        public Project getProject()
        INTERNAL: Return the core API Project associated with the DatabaseSession that is associated with this Metamodel
        Returns:
      • getSession

        protected AbstractSession getSession()
        INTERNAL: Return the DatabaseSession associated with this Metamodel
        Returns:
      • getType

        public <X> TypeImpl<X> getType​(Class<X> javaClass)
        INTERNAL: Return a Type representation of a java Class for use by the Metamodel Attributes.

        If a type does not yet exist - one will be created and added to the Metamodel - this usually only for Basic types.

        This function will handle all Metamodel defined and core java classes.

        Parameters:
        javaClass -
        Returns:
      • getTypes

        public Map<String,​TypeImpl<?>> getTypes()
        INTERNAL: Return the Map of types on this metamodel. This includes all Entity, MappedSuperclass, Embeddable and Basic types
        Returns:
      • hasMappedSuperclass

        protected boolean hasMappedSuperclass​(String qualifiedClassNameKeyString)
        INTERNAL: Return whether there is a descriptor that is keyed by the supplied class name.

        Referenced by ManagedTypeImpl.create()

        Parameters:
        qualifiedClassNameKeyString -
        Returns:
      • isInitialized

        public boolean isInitialized()
      • initialize

        public void initialize​(ClassLoader classLoader)
        INTERNAL: Initialize the JPA metamodel that wraps the EclipseLink JPA metadata created descriptors.
        Note: Since the types Map is lazy-loaded with key:value pairs - the designer and especially the user must realized that a particular BasicType may not be in the Map until it is referenced. Also note that a transient superclass (non-entity, non-mappedSuperclass) exists as a BasicType (it has no attributes), and that any inheriting Entity either directly subclassing or indirectly subclassing via a MappedSuperclass inheritance chain - does not pick up non-persistence fields that normally would be inherited. (The fields exist in Java but not in ORM:Metamodel) The transient class will have no JPA annotations. This is the second phase of metamodel initialization. It causes preindexed classes to have their attributes populated.
      • managedType

        public <X> jakarta.persistence.metamodel.ManagedType<X> managedType​(Class<X> clazz)
        Return the metamodel managed type representing the entity, mapped superclass, or embeddable class.
        Specified by:
        managedType in interface jakarta.persistence.metamodel.Metamodel
        Parameters:
        clazz - the type of the represented managed class
        Returns:
        the metamodel managed type
        Throws:
        IllegalArgumentException - if not a managed class
      • printAllTypes

        public void printAllTypes()
        INTERNAL: Print out all the Type attributes in the Metamodel
      • toString

        public String toString()
        INTERNAL: Return the string representation of the receiver.
        Overrides:
        toString in class Object