Class ManagedTypeImpl<X>
- java.lang.Object
-
- org.eclipse.persistence.internal.jpa.metamodel.TypeImpl<X>
-
- org.eclipse.persistence.internal.jpa.metamodel.ManagedTypeImpl<X>
-
- Type Parameters:
X- The represented type.
- All Implemented Interfaces:
jakarta.persistence.metamodel.ManagedType<X>,jakarta.persistence.metamodel.Type<X>,Serializable
- Direct Known Subclasses:
EmbeddableTypeImpl,IdentifiableTypeImpl
public abstract class ManagedTypeImpl<X> extends TypeImpl<X> implements jakarta.persistence.metamodel.ManagedType<X>
Purpose: Provides the implementation for the ManagedType interface of the JPA 2.0 Metamodel API (part of the JSR-317 EJB 3.1 Criteria API)
Description: Instances of the type ManagedType represent entities, mapped superclasses and embeddable types.
- Since:
- EclipseLink 1.2 - JPA 2.0
- See Also:
ManagedType, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected ClassDescriptordescriptorNative RelationalDescriptor that contains all the mappings of this typeprotected MetamodelImplmetamodelReference to the metamodel that this managed type belongs to
-
Constructor Summary
Constructors Modifier Constructor Description protectedManagedTypeImpl(MetamodelImpl metamodel, ClassDescriptor descriptor)INTERNAL: This constructor will create a ManagedType but will not initialize its member mappings.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static ManagedTypeImpl<?>create(MetamodelImpl metamodel, ClassDescriptor descriptor)INTERNAL: Return an instance of a ManagedType based on the RelationalDescriptor parameterjakarta.persistence.metamodel.Attribute<X,?>getAttribute(String name)Return the attribute of the managed type that corresponds to the specified name.Set<jakarta.persistence.metamodel.Attribute<? super X,?>>getAttributes()Return the attributes of the managed type.jakarta.persistence.metamodel.CollectionAttribute<? super X,?>getCollection(String name)Return the Collection-valued attribute of the managed type that corresponds to the specified name.<E> jakarta.persistence.metamodel.CollectionAttribute<? super X,E>getCollection(String name, Class<E> elementType)Return the Collection-valued attribute of the managed type that corresponds to the specified name and Java element type.jakarta.persistence.metamodel.Attribute<X,?>getDeclaredAttribute(String name)Return the declared attribute of the managed type that corresponds to the specified name.protected jakarta.persistence.metamodel.Attribute<X,?>getDeclaredAttribute(String name, boolean attributeKnownToExistOnLeafTarget)INTERNAL: Return the declared attribute of the managed type that corresponds to the specified name.Set<jakarta.persistence.metamodel.Attribute<X,?>>getDeclaredAttributes()Return the attributes declared by the managed type.jakarta.persistence.metamodel.CollectionAttribute<X,?>getDeclaredCollection(String name)Return the Collection-valued attribute declared by the managed type that corresponds to the specified name.<E> jakarta.persistence.metamodel.CollectionAttribute<X,E>getDeclaredCollection(String name, Class<E> elementType)Return the Collection-valued attribute declared by the managed type that corresponds to the specified name and Java element type.jakarta.persistence.metamodel.ListAttribute<X,?>getDeclaredList(String name)Return the List-valued attribute declared by the managed type that corresponds to the specified name.<E> jakarta.persistence.metamodel.ListAttribute<X,E>getDeclaredList(String name, Class<E> elementType)Return the List-valued attribute declared by the managed type that corresponds to the specified name and Java element type.jakarta.persistence.metamodel.MapAttribute<X,?,?>getDeclaredMap(String name)Return the Map-valued attribute of the managed type that corresponds to the specified name.<K,V>
jakarta.persistence.metamodel.MapAttribute<X,K,V>getDeclaredMap(String name, Class<K> keyType, Class<V> valueType)Return the Map-valued attribute of the managed type that corresponds to the specified name and Java key and value types.Set<jakarta.persistence.metamodel.PluralAttribute<X,?,?>>getDeclaredPluralAttributes()Return all collection-valued attributes declared by the managed type.jakarta.persistence.metamodel.SetAttribute<X,?>getDeclaredSet(String name)Return the Set-valued attribute declared by the managed type that corresponds to the specified name.<E> jakarta.persistence.metamodel.SetAttribute<X,E>getDeclaredSet(String name, Class<E> elementType)Return the Set-valued attribute declared by the managed type that corresponds to the specified name and Java element type.jakarta.persistence.metamodel.SingularAttribute<X,?>getDeclaredSingularAttribute(String name)Return the declared single-valued attribute of the managed type that corresponds to the specified name in the represented type.<Y> jakarta.persistence.metamodel.SingularAttribute<X,Y>getDeclaredSingularAttribute(String name, Class<Y> type)Return the declared single-valued attribute of the managed type that corresponds to the specified name and Java type in the represented type.Set<jakarta.persistence.metamodel.SingularAttribute<X,?>>getDeclaredSingularAttributes()Return the single-valued attributes declared by the managed type.ClassDescriptorgetDescriptor()INTERNAL: Return the RelationalDescriptor associated with this ManagedTypejakarta.persistence.metamodel.ListAttribute<? super X,?>getList(String name)Return the List-valued attribute of the managed type that corresponds to the specified name.<E> jakarta.persistence.metamodel.ListAttribute<? super X,E>getList(String name, Class<E> elementType)Return the List-valued attribute of the managed type that corresponds to the specified name and Java element type.jakarta.persistence.metamodel.MapAttribute<? super X,?,?>getMap(String name)Return the Map-valued attribute of the managed type that corresponds to the specified name.<K,V>
jakarta.persistence.metamodel.MapAttribute<? super X,K,V>getMap(String name, Class<K> keyType, Class<V> valueType)Return the Map-valued attribute of the managed type that corresponds to the specified name and Java key and value types.protected Map<String,jakarta.persistence.metamodel.Attribute<X,?>>getMembers()INTERNAL: Return the Map of AttributeImpl members keyed by String.protected MetamodelImplgetMetamodel()INTERNAL: Return the Metamodel that this ManagedType is associated with.Set<jakarta.persistence.metamodel.PluralAttribute<? super X,?,?>>getPluralAttributes()Return all collection-valued attributes of the managed type.jakarta.persistence.metamodel.SetAttribute<? super X,?>getSet(String name)Return the Set-valued attribute of the managed type that corresponds to the specified name.<E> jakarta.persistence.metamodel.SetAttribute<? super X,E>getSet(String name, Class<E> elementType)Return the Set-valued attribute of the managed type that corresponds to the specified name and Java element type.jakarta.persistence.metamodel.SingularAttribute<? super X,?>getSingularAttribute(String name)Return the single-valued attribute of the managed type that corresponds to the specified name in the represented type.<Y> jakarta.persistence.metamodel.SingularAttribute<? super X,Y>getSingularAttribute(String name, Class<Y> type)Return the single-valued attribute of the managed type that corresponds to the specified name and Java type in the represented type.Set<jakarta.persistence.metamodel.SingularAttribute<? super X,?>>getSingularAttributes()Return the single-valued attributes of the managed type.protected ClassgetTypeClassFromAttributeOrMethodLevelAccessor(DatabaseMapping mapping)INTERNAL: Get the elementType directly from the class using a reflective method call directly on the containing java class associated with this managedType.protected voidinitialize()INTERNAL: Initialize the members of this ManagedType based on the mappings defined on the descriptor.protected booleanisIdentifiableType()INTERNAL: Return whether this type is identifiable.protected booleanisManagedType()INTERNAL: Return whether this type is identifiable.protected voidtoStringHelper(StringBuffer aBuffer)INTERNAL: Append the partial string representation of the receiver to the StringBuffer.-
Methods inherited from class org.eclipse.persistence.internal.jpa.metamodel.TypeImpl
getJavaType, getJavaType, getJavaTypeName, isEntity, isMappedSuperclass, toString
-
-
-
-
Field Detail
-
descriptor
protected ClassDescriptor descriptor
Native RelationalDescriptor that contains all the mappings of this type
-
metamodel
protected MetamodelImpl metamodel
Reference to the metamodel that this managed type belongs to
-
-
Constructor Detail
-
ManagedTypeImpl
protected ManagedTypeImpl(MetamodelImpl metamodel, ClassDescriptor descriptor)
INTERNAL: This constructor will create a ManagedType but will not initialize its member mappings. This is accomplished by delayed initialization in MetamodelImpl.initialize() in order that we have access to all types when resolving relationships in mappings.- Parameters:
metamodel- - the metamodel that this managedType is associated withdescriptor- - the RelationalDescriptor that defines this managedType
-
-
Method Detail
-
getAttribute
public jakarta.persistence.metamodel.Attribute<X,?> getAttribute(String name)
Return the attribute of the managed type that corresponds to the specified name.- Specified by:
getAttributein interfacejakarta.persistence.metamodel.ManagedType<X>- Parameters:
name- the name of the represented attribute- Returns:
- attribute with given name
- Throws:
IllegalArgumentException- if attribute of the given name is not present in the managed type
-
getAttributes
public Set<jakarta.persistence.metamodel.Attribute<? super X,?>> getAttributes()
Return the attributes of the managed type.- Specified by:
getAttributesin interfacejakarta.persistence.metamodel.ManagedType<X>
-
getCollection
public jakarta.persistence.metamodel.CollectionAttribute<? super X,?> getCollection(String name)
Return the Collection-valued attribute of the managed type that corresponds to the specified name.- Specified by:
getCollectionin interfacejakarta.persistence.metamodel.ManagedType<X>- Parameters:
name- the name of the represented attribute- Returns:
- CollectionAttribute of the given name
- Throws:
IllegalArgumentException- if attribute of the given name is not present in the managed type
-
getCollection
public <E> jakarta.persistence.metamodel.CollectionAttribute<? super X,E> getCollection(String name, Class<E> elementType)
Return the Collection-valued attribute of the managed type that corresponds to the specified name and Java element type.- Specified by:
getCollectionin interfacejakarta.persistence.metamodel.ManagedType<X>- Parameters:
name- the name of the represented attributeelementType- the element type of the represented attribute- Returns:
- CollectionAttribute of the given name and element type
- Throws:
IllegalArgumentException- if attribute of the given name and type is not present in the managed type
-
getPluralAttributes
public Set<jakarta.persistence.metamodel.PluralAttribute<? super X,?,?>> getPluralAttributes()
Return all collection-valued attributes of the managed type.- Specified by:
getPluralAttributesin interfacejakarta.persistence.metamodel.ManagedType<X>- Returns:
- collection valued attributes
-
getDeclaredAttribute
protected jakarta.persistence.metamodel.Attribute<X,?> getDeclaredAttribute(String name, boolean attributeKnownToExistOnLeafTarget)
INTERNAL: Return the declared attribute of the managed type that corresponds to the specified name.- Parameters:
name- the name of the represented attributeattributeKnownToExistOnLeafTarget- true if we already know the attribute exists on the leaf- Returns:
- attribute with given name
- Throws:
IllegalArgumentException- if attribute of the given name is not declared in the managed type
-
getDeclaredAttribute
public jakarta.persistence.metamodel.Attribute<X,?> getDeclaredAttribute(String name)
Return the declared attribute of the managed type that corresponds to the specified name.- Specified by:
getDeclaredAttributein interfacejakarta.persistence.metamodel.ManagedType<X>- Parameters:
name- the name of the represented attribute- Returns:
- attribute with given name
- Throws:
IllegalArgumentException- if attribute of the given name is not declared in the managed type
-
getDeclaredAttributes
public Set<jakarta.persistence.metamodel.Attribute<X,?>> getDeclaredAttributes()
Return the attributes declared by the managed type.- Specified by:
getDeclaredAttributesin interfacejakarta.persistence.metamodel.ManagedType<X>
-
getDeclaredCollection
public jakarta.persistence.metamodel.CollectionAttribute<X,?> getDeclaredCollection(String name)
Return the Collection-valued attribute declared by the managed type that corresponds to the specified name.- Specified by:
getDeclaredCollectionin interfacejakarta.persistence.metamodel.ManagedType<X>- Parameters:
name- the name of the represented attribute- Returns:
- declared CollectionAttribute of the given name
- Throws:
IllegalArgumentException- if attribute of the given name is not declared in the managed type
-
getDeclaredCollection
public <E> jakarta.persistence.metamodel.CollectionAttribute<X,E> getDeclaredCollection(String name, Class<E> elementType)
Return the Collection-valued attribute declared by the managed type that corresponds to the specified name and Java element type.- Specified by:
getDeclaredCollectionin interfacejakarta.persistence.metamodel.ManagedType<X>- Parameters:
name- the name of the represented attributeelementType- the element type of the represented attribute- Returns:
- declared CollectionAttribute of the given name and element type
- Throws:
IllegalArgumentException- if attribute of the given name and type is not declared in the managed type
-
getDeclaredPluralAttributes
public Set<jakarta.persistence.metamodel.PluralAttribute<X,?,?>> getDeclaredPluralAttributes()
Return all collection-valued attributes declared by the managed type.- Specified by:
getDeclaredPluralAttributesin interfacejakarta.persistence.metamodel.ManagedType<X>- Returns:
- declared collection valued attributes
-
create
protected static ManagedTypeImpl<?> create(MetamodelImpl metamodel, ClassDescriptor descriptor)
INTERNAL: Return an instance of a ManagedType based on the RelationalDescriptor parameter- Parameters:
metamodel-descriptor-- Returns:
-
getDeclaredList
public <E> jakarta.persistence.metamodel.ListAttribute<X,E> getDeclaredList(String name, Class<E> elementType)
Return the List-valued attribute declared by the managed type that corresponds to the specified name and Java element type.- Specified by:
getDeclaredListin interfacejakarta.persistence.metamodel.ManagedType<X>- Parameters:
name- the name of the represented attributeelementType- the element type of the represented attribute- Returns:
- declared ListAttribute of the given name and element type
- Throws:
IllegalArgumentException- if attribute of the given name and type is not declared in the managed type
-
getDeclaredList
public jakarta.persistence.metamodel.ListAttribute<X,?> getDeclaredList(String name)
Return the List-valued attribute declared by the managed type that corresponds to the specified name.- Specified by:
getDeclaredListin interfacejakarta.persistence.metamodel.ManagedType<X>- Parameters:
name- the name of the represented attribute- Returns:
- declared ListAttribute of the given name
- Throws:
IllegalArgumentException- if attribute of the given name is not declared in the managed type
-
getDeclaredMap
public jakarta.persistence.metamodel.MapAttribute<X,?,?> getDeclaredMap(String name)
Return the Map-valued attribute of the managed type that corresponds to the specified name.- Specified by:
getDeclaredMapin interfacejakarta.persistence.metamodel.ManagedType<X>- Parameters:
name- the name of the represented attribute- Returns:
- MapAttribute of the given name
- Throws:
IllegalArgumentException- if attribute of the given name is not present in the managed type
-
getDeclaredMap
public <K,V> jakarta.persistence.metamodel.MapAttribute<X,K,V> getDeclaredMap(String name, Class<K> keyType, Class<V> valueType)
Return the Map-valued attribute of the managed type that corresponds to the specified name and Java key and value types.- Specified by:
getDeclaredMapin interfacejakarta.persistence.metamodel.ManagedType<X>- Parameters:
name- the name of the represented attributekeyType- the key type of the represented attributevalueType- the value type of the represented attribute- Returns:
- MapAttribute of the given name and key and value types
- Throws:
IllegalArgumentException- if attribute of the given name and type is not present in the managed type
-
getDeclaredSet
public jakarta.persistence.metamodel.SetAttribute<X,?> getDeclaredSet(String name)
Return the Set-valued attribute declared by the managed type that corresponds to the specified name.- Specified by:
getDeclaredSetin interfacejakarta.persistence.metamodel.ManagedType<X>- Parameters:
name- the name of the represented attribute- Returns:
- declared SetAttribute of the given name
- Throws:
IllegalArgumentException- if attribute of the given name is not declared in the managed type
-
getDeclaredSet
public <E> jakarta.persistence.metamodel.SetAttribute<X,E> getDeclaredSet(String name, Class<E> elementType)
Return the Set-valued attribute declared by the managed type that corresponds to the specified name and Java element type.- Specified by:
getDeclaredSetin interfacejakarta.persistence.metamodel.ManagedType<X>- Parameters:
name- the name of the represented attributeelementType- the element type of the represented attribute- Returns:
- declared SetAttribute of the given name and element type
- Throws:
IllegalArgumentException- if attribute of the given name and type is not declared in the managed type
-
getDeclaredSingularAttribute
public jakarta.persistence.metamodel.SingularAttribute<X,?> getDeclaredSingularAttribute(String name)
Return the declared single-valued attribute of the managed type that corresponds to the specified name in the represented type.- Specified by:
getDeclaredSingularAttributein interfacejakarta.persistence.metamodel.ManagedType<X>- Parameters:
name- the name of the represented attribute- Returns:
- declared single-valued attribute of the given name
- Throws:
IllegalArgumentException- if attribute of the given name is not declared in the managed type
-
getDeclaredSingularAttribute
public <Y> jakarta.persistence.metamodel.SingularAttribute<X,Y> getDeclaredSingularAttribute(String name, Class<Y> type)
Return the declared single-valued attribute of the managed type that corresponds to the specified name and Java type in the represented type.- Specified by:
getDeclaredSingularAttributein interfacejakarta.persistence.metamodel.ManagedType<X>- Parameters:
name- the name of the represented attributetype- the type of the represented attribute- Returns:
- declared single-valued attribute of the given name and type
- Throws:
IllegalArgumentException- if attribute of the given name and type is not declared in the managed type
-
getDeclaredSingularAttributes
public Set<jakarta.persistence.metamodel.SingularAttribute<X,?>> getDeclaredSingularAttributes()
Return the single-valued attributes declared by the managed type.- Specified by:
getDeclaredSingularAttributesin interfacejakarta.persistence.metamodel.ManagedType<X>- Returns:
- declared single-valued attributes
-
getDescriptor
public ClassDescriptor getDescriptor()
INTERNAL: Return the RelationalDescriptor associated with this ManagedType- Returns:
-
getList
public jakarta.persistence.metamodel.ListAttribute<? super X,?> getList(String name)
Return the List-valued attribute of the managed type that corresponds to the specified name.- Specified by:
getListin interfacejakarta.persistence.metamodel.ManagedType<X>- Parameters:
name- the name of the represented attribute- Returns:
- ListAttribute of the given name
- Throws:
IllegalArgumentException- if attribute of the given name is not present in the managed type
-
getList
public <E> jakarta.persistence.metamodel.ListAttribute<? super X,E> getList(String name, Class<E> elementType)
Return the List-valued attribute of the managed type that corresponds to the specified name and Java element type.- Specified by:
getListin interfacejakarta.persistence.metamodel.ManagedType<X>- Parameters:
name- the name of the represented attributeelementType- the element type of the represented attribute- Returns:
- ListAttribute of the given name and element type
- Throws:
IllegalArgumentException- if attribute of the given name and type is not present in the managed type
-
getMap
public jakarta.persistence.metamodel.MapAttribute<? super X,?,?> getMap(String name)
Return the Map-valued attribute of the managed type that corresponds to the specified name.- Specified by:
getMapin interfacejakarta.persistence.metamodel.ManagedType<X>- Parameters:
name- the name of the represented attribute- Returns:
- MapAttribute of the given name
- Throws:
IllegalArgumentException- if attribute of the given name is not present in the managed type
-
getMap
public <K,V> jakarta.persistence.metamodel.MapAttribute<? super X,K,V> getMap(String name, Class<K> keyType, Class<V> valueType)
Return the Map-valued attribute of the managed type that corresponds to the specified name and Java key and value types.- Specified by:
getMapin interfacejakarta.persistence.metamodel.ManagedType<X>- Parameters:
name- the name of the represented attributekeyType- the key type of the represented attributevalueType- the value type of the represented attribute- Returns:
- MapAttribute of the given name and key and value types
- Throws:
IllegalArgumentException- if attribute of the given name and type is not present in the managed type
-
getMembers
protected Map<String,jakarta.persistence.metamodel.Attribute<X,?>> getMembers()
INTERNAL: Return the Map of AttributeImpl members keyed by String.- Returns:
-
getMetamodel
protected MetamodelImpl getMetamodel()
INTERNAL: Return the Metamodel that this ManagedType is associated with.- Returns:
-
getSet
public jakarta.persistence.metamodel.SetAttribute<? super X,?> getSet(String name)
Return the Set-valued attribute of the managed type that corresponds to the specified name.- Specified by:
getSetin interfacejakarta.persistence.metamodel.ManagedType<X>- Parameters:
name- the name of the represented attribute- Returns:
- SetAttribute of the given name
- Throws:
IllegalArgumentException- if attribute of the given name is not present in the managed type
-
getSet
public <E> jakarta.persistence.metamodel.SetAttribute<? super X,E> getSet(String name, Class<E> elementType)
Return the Set-valued attribute of the managed type that corresponds to the specified name and Java element type.- Specified by:
getSetin interfacejakarta.persistence.metamodel.ManagedType<X>- Parameters:
name- the name of the represented attributeelementType- the element type of the represented attribute- Returns:
- SetAttribute of the given name and element type
- Throws:
IllegalArgumentException- if attribute of the given name and type is not present in the managed type
-
getSingularAttribute
public jakarta.persistence.metamodel.SingularAttribute<? super X,?> getSingularAttribute(String name)
Return the single-valued attribute of the managed type that corresponds to the specified name in the represented type.- Specified by:
getSingularAttributein interfacejakarta.persistence.metamodel.ManagedType<X>- Parameters:
name- the name of the represented attribute- Returns:
- single-valued attribute with the given name
- Throws:
IllegalArgumentException- if attribute of the given name is not present in the managed type
-
getSingularAttribute
public <Y> jakarta.persistence.metamodel.SingularAttribute<? super X,Y> getSingularAttribute(String name, Class<Y> type)
Return the single-valued attribute of the managed type that corresponds to the specified name and Java type in the represented type.- Specified by:
getSingularAttributein interfacejakarta.persistence.metamodel.ManagedType<X>- Parameters:
name- the name of the represented attributetype- the type of the represented attribute- Returns:
- single-valued attribute with given name and type
- Throws:
IllegalArgumentException- if attribute of the given name and type is not present in the managed type
-
getSingularAttributes
public Set<jakarta.persistence.metamodel.SingularAttribute<? super X,?>> getSingularAttributes()
Return the single-valued attributes of the managed type.- Specified by:
getSingularAttributesin interfacejakarta.persistence.metamodel.ManagedType<X>- Returns:
- single-valued attributes
-
initialize
protected void initialize()
INTERNAL: Initialize the members of this ManagedType based on the mappings defined on the descriptor. We process the appropriate Map, List, Set, Collection or Object/primitive types.Initialization should occur after all types in the metamodel have been created already.
-
getTypeClassFromAttributeOrMethodLevelAccessor
protected Class getTypeClassFromAttributeOrMethodLevelAccessor(DatabaseMapping mapping)
INTERNAL: Get the elementType directly from the class using a reflective method call directly on the containing java class associated with this managedType.- Parameters:
mapping-- Returns:
-
isIdentifiableType
protected boolean isIdentifiableType()
INTERNAL: Return whether this type is identifiable. This would be EntityType and MappedSuperclassType- Specified by:
isIdentifiableTypein classTypeImpl<X>- Returns:
-
isManagedType
protected boolean isManagedType()
INTERNAL: Return whether this type is identifiable. This would be EmbeddableType as well as EntityType and MappedSuperclassType- Specified by:
isManagedTypein classTypeImpl<X>- Returns:
-
toStringHelper
protected void toStringHelper(StringBuffer aBuffer)
INTERNAL: Append the partial string representation of the receiver to the StringBuffer.- Specified by:
toStringHelperin classTypeImpl<X>
-
-