Top Description Fields Constructors Methods
org.eclipse.persistence.internal.jpa.metamodel

public Class MetamodelImpl

extends Object
implements Metamodel, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, jakarta.persistence.metamodel.Metamodel
Imports
java.io.Serializable, java.util.ArrayList, .LinkedHashMap, .LinkedHashSet, .List, .Map, .Set, jakarta.persistence.EntityManager, .EntityManagerFactory, jakarta.persistence.metamodel.Attribute, .EmbeddableType, .EntityType, .IdentifiableType, .ManagedType, .Metamodel, .Type, .Type.PersistenceType, org.eclipse.persistence.descriptors.ClassDescriptor, org.eclipse.persistence.internal.helper.ClassConstants, org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl, org.eclipse.persistence.internal.localization.ExceptionLocalization, org.eclipse.persistence.internal.sessions.AbstractSession, org.eclipse.persistence.jpa.JpaHelper, org.eclipse.persistence.logging.AbstractSessionLog, .SessionLog, org.eclipse.persistence.sessions.Project

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
jakarta.persistence.metamodel.Metamodel

Field Summary

Modifier and TypeField and Description
public static final Class<Object>
DEFAULT_ELEMENT_TYPE_FOR_UNSUPPORTED_MAPPINGS

Default elementType Class when we the type cannot be determined for unsupported mappings such as Transformation and VariableOneToOne

private Map<String, EmbeddableTypeImpl<?>>
embeddables

The Map of embeddables in this metamodel keyed on Class

private Map<String, EntityTypeImpl<?>>
entities

The Map of entities in this metamodel keyed on Class

private boolean
isInitialized

maintains initialization state to avoid extra work in calls to initialize

private Map<String, ManagedTypeImpl<?>>
managedTypes

The Map of managed types (Entity, Embeddable and MappedSuperclass) in this metamodel keyed on Class

private Set<MappedSuperclassTypeImpl<?>>
mappedSuperclasses

The Set of MappedSuperclassTypes in this metamodel

private static final long
serialVersionUID

Item 54: DI 89: explicit UID will avoid performance hit runtime generation of one

private AbstractSession
session

The EclipseLink Session associated with this Metamodel implementation that contains all our descriptors with mappings

private Map<String, TypeImpl<?>>
types

The Map of types (Entity, Embeddable, MappedSuperclass and Basic - essentially Basic + managedTypes) in this metamodel keyed on Class

Constructor Summary

AccessConstructor and Description
public
public
public
public
MetamodelImpl(EntityManagerSetupImpl emSetupImpl)

INTERNAL:

Method Summary

Modifier and TypeMethod and Description
public <X> EmbeddableType<X>

Returns:

the metamodel embeddable type
embeddable
(Class<X>
the type of the represented embeddable class
clazz
)

Implements jakarta.persistence.metamodel.Metamodel.embeddable.

Return the metamodel embeddable type representing the embeddable class.
public <X> EntityType<X>

Returns:

the metamodel entity type
entity
(Class<X>
the type of the represented entity
clazz
)

Implements jakarta.persistence.metamodel.Metamodel.entity.

Return the metamodel entity type representing the entity.
private void
entityEmbeddableManagedTypeNotFound(Map<K, V> typeMap, Object aType, Class<?> clazz, String metamodelType, String metamodelTypeName)

INTERNAL: This function will warn the user and/or throw an IllegalArgumentException if the type is not found in the metamodel.

public List<Attribute<X, Y>>
getAllManagedTypeAttributes()

INTERNAL: Return a List of all attributes for all ManagedTypes.

public Set<EmbeddableType<?>>

Returns:

the metamodel embeddable types
getEmbeddables
()

Implements jakarta.persistence.metamodel.Metamodel.getEmbeddables.

Return the metamodel embeddable types.
public Set<EntityType<?>>

Returns:

the metamodel entity types
getEntities
()

Implements jakarta.persistence.metamodel.Metamodel.getEntities.

Return the metamodel entity types.
public Set<ManagedType<?>>

Returns:

the metamodel managed types
getManagedTypes
()

Implements jakarta.persistence.metamodel.Metamodel.getManagedTypes.

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

Return the metamodel managed types map.

public Set<MappedSuperclassTypeImpl<?>>
getMappedSuperclasses()

INTERNAL: Return the Set of MappedSuperclassType objects

public Project
getProject()

INTERNAL: Return the core API Project associated with the DatabaseSession that is associated with this Metamodel

protected AbstractSession
getSession()

INTERNAL: Return the DatabaseSession associated with this Metamodel

public <X> TypeImpl<X>
getType(Class<X> javaClass)

INTERNAL: Return a Type representation of a java Class for use by the Metamodel Attributes.

public Map<String, TypeImpl<?>>
getTypes()

INTERNAL: Return the Map of types on this metamodel.

protected boolean
hasMappedSuperclass(String qualifiedClassNameKeyString)

INTERNAL: Return whether there is a descriptor that is keyed by the supplied class name.

public void
initialize(ClassLoader classLoader)

INTERNAL: Initialize the JPA metamodel that wraps the EclipseLink JPA metadata created descriptors.

public boolean
public <X> ManagedType<X>

Returns:

the metamodel managed type
managedType
(Class<X>
the type of the represented managed class
clazz
)

Implements jakarta.persistence.metamodel.Metamodel.managedType.

Return the metamodel managed type representing the entity, mapped superclass, or embeddable class.
private void
preInitialize()

INTERNAL: First phase of metamodel intialization.

public void
printAllTypes()

INTERNAL: Print out all the Type attributes in the Metamodel

private boolean
putType(String javaClassKey, TypeImpl<X> typeValue)

INTERNAL: This function is a wrapper around a Map.put(K,V) We return a boolean that is unused but provides a way to add a breakpoint for the false condition.

public String
toString()

Overrides java.lang.Object.toString.

INTERNAL: Return the string representation of the receiver.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

DEFAULT_ELEMENT_TYPE_FOR_UNSUPPORTED_MAPPINGSback to summary
public static final Class<Object> DEFAULT_ELEMENT_TYPE_FOR_UNSUPPORTED_MAPPINGS

Default elementType Class when we the type cannot be determined for unsupported mappings such as Transformation and VariableOneToOne

embeddablesback to summary
private Map<String, EmbeddableTypeImpl<?>> embeddables

The Map of embeddables in this metamodel keyed on Class

entitiesback to summary
private Map<String, EntityTypeImpl<?>> entities

The Map of entities in this metamodel keyed on Class

isInitializedback to summary
private boolean isInitialized

maintains initialization state to avoid extra work in calls to initialize

managedTypesback to summary
private Map<String, ManagedTypeImpl<?>> managedTypes

The Map of managed types (Entity, Embeddable and MappedSuperclass) in this metamodel keyed on Class

mappedSuperclassesback to summary
private Set<MappedSuperclassTypeImpl<?>> mappedSuperclasses

The Set of MappedSuperclassTypes in this metamodel

serialVersionUIDback to summary
private static final long serialVersionUID

Item 54: DI 89: explicit UID will avoid performance hit runtime generation of one

sessionback to summary
private AbstractSession session

The EclipseLink Session associated with this Metamodel implementation that contains all our descriptors with mappings

typesback to summary
private Map<String, TypeImpl<?>> types

The Map of types (Entity, Embeddable, MappedSuperclass and Basic - essentially Basic + managedTypes) in this metamodel keyed on Class

Constructor Detail

MetamodelImplback to summary
public MetamodelImpl(AbstractSession session)
MetamodelImplback to summary
public MetamodelImpl(EntityManager em)
MetamodelImplback to summary
public MetamodelImpl(EntityManagerFactory emf)
MetamodelImplback to summary
public MetamodelImpl(EntityManagerSetupImpl emSetupImpl)

INTERNAL:

Method Detail

embeddableback to summary
public <X> EmbeddableType<X> embeddable(Class<X> clazz)

Implements jakarta.persistence.metamodel.Metamodel.embeddable.

Return the metamodel embeddable type representing the embeddable class.

Parameters
clazz:Class<X>

the type of the represented embeddable class

Returns:EmbeddableType<X>

the metamodel embeddable type

Annotations
@Override
Exceptions
IllegalArgumentException:
if not an embeddable class
entityback to summary
public <X> EntityType<X> entity(Class<X> clazz)

Implements jakarta.persistence.metamodel.Metamodel.entity.

Return the metamodel entity type representing the entity.

Parameters
clazz:Class<X>

the type of the represented entity

Returns:EntityType<X>

the metamodel entity type

Annotations
@Override
Exceptions
IllegalArgumentException:
if not an entity
entityEmbeddableManagedTypeNotFoundback to summary
private void entityEmbeddableManagedTypeNotFound(Map<K, V> typeMap, Object aType, Class<?> clazz, String metamodelType, String metamodelTypeName)

INTERNAL: This function will warn the user and/or throw an IllegalArgumentException if the type is not found in the metamodel. There is a chance that the entire metamodel is empty because the model was not found during entity search. This is usually due to the case where an expected managed persistence unit in a Java EE environment is actually processed as a Java SE (unmanaged) persistence unit. This may occur on certain configurations of Spring or on Java EE 6 Web Profile implementations that are not in compliance with the specification. See http://bugs.eclipse.org/338837

getAllManagedTypeAttributesback to summary
public List<Attribute<X, Y>> getAllManagedTypeAttributes()

INTERNAL: Return a List of all attributes for all ManagedTypes.

getEmbeddablesback to summary
public Set<EmbeddableType<?>> getEmbeddables()

Implements jakarta.persistence.metamodel.Metamodel.getEmbeddables.

Return the metamodel embeddable types.

Returns:Set<EmbeddableType<?>>

the metamodel embeddable types

Annotations
@Override
getEntitiesback to summary
public Set<EntityType<?>> getEntities()

Implements jakarta.persistence.metamodel.Metamodel.getEntities.

Return the metamodel entity types.

Returns:Set<EntityType<?>>

the metamodel entity types

Annotations
@Override
getManagedTypesback to summary
public Set<ManagedType<?>> getManagedTypes()

Implements jakarta.persistence.metamodel.Metamodel.getManagedTypes.

Return the metamodel managed types.

Returns:Set<ManagedType<?>>

the metamodel managed types

Annotations
@Override
getManagedTypesMapback to summary
public Map<String, ManagedTypeImpl<?>> getManagedTypesMap()

Return the metamodel managed types map.

getMappedSuperclassesback to summary
public Set<MappedSuperclassTypeImpl<?>> getMappedSuperclasses()

INTERNAL: Return the Set of MappedSuperclassType objects

getProjectback to summary
public Project getProject()

INTERNAL: Return the core API Project associated with the DatabaseSession that is associated with this Metamodel

getSessionback to summary
protected AbstractSession getSession()

INTERNAL: Return the DatabaseSession associated with this Metamodel

getTypeback to summary
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.

getTypesback to summary
public Map<String, TypeImpl<?>> getTypes()

INTERNAL: Return the Map of types on this metamodel. This includes all Entity, MappedSuperclass, Embeddable and Basic types

hasMappedSuperclassback to summary
protected boolean hasMappedSuperclass(String qualifiedClassNameKeyString)

INTERNAL: Return whether there is a descriptor that is keyed by the supplied class name.

Referenced by ManagedTypeImpl.create()

initializeback to summary
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.

isInitializedback to summary
public boolean isInitialized()
managedTypeback to summary
public <X> ManagedType<X> managedType(Class<X> clazz)

Implements jakarta.persistence.metamodel.Metamodel.managedType.

Return the metamodel managed type representing the entity, mapped superclass, or embeddable class.

Parameters
clazz:Class<X>

the type of the represented managed class

Returns:ManagedType<X>

the metamodel managed type

Annotations
@Override
Exceptions
IllegalArgumentException:
if not a managed class
preInitializeback to summary
private void preInitialize()

INTERNAL: First phase of metamodel intialization. Builds a list of the classes in the metamodel and stores them in appropriate lists indexed by the classname. We index by classname to avoid having to load classes at this phase of initialization

printAllTypesback to summary
public void printAllTypes()

INTERNAL: Print out all the Type attributes in the Metamodel

putTypeback to summary
private boolean putType(String javaClassKey, TypeImpl<X> typeValue)

INTERNAL: This function is a wrapper around a Map.put(K,V)
We return a boolean that is unused but provides a way to add a breakpoint for the false condition.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

INTERNAL: Return the string representation of the receiver.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.

Annotations
@Override