Le point d’accès est Metamodel, accessible depuis l’entity manager.
Metamodel metamodel = entityManager.getMetamodel();
//...
Métadonnées des entités
Pour chaque entité, on a un objet EntityType accessible depuis le metamodel.
EntityType<Product> productEntityType = metamodel.entity(Product.class);
// ou
Set<ManagedType<?>> managedTypes = metamodel.getManagedTypes();
-
EntityType<X> → IdentifiableType<X> → ManagedType<X> → Type<X>
-
getName(): String
-
getJavaType(): Class<X>
-
getAttributes(): Set<Attribute<? super X, ?>>
-
getAttribute(String name): Attribute<? super X, ?>
-
getSingularAttributes(): Set<SingularAttribute<? super X, ?>>
-
getSingularAttribute(String name): SingularAttribute<? super X, ?>
-
getSingularAttribute(String name, Class<Y> type): SingularAttribute<? super X, Y>
-
getPluralAttributes(): Set<PluralAttribute<? super X, ?, ?>>
-
getCollection(String name): CollectionAttribute<? super X, ?>
-
getCollection(String name, Class<E> elementType): CollectionAttribute<? super X, E>
-
getSet(String name, Class<E> elementType): SetAttribute<? super X, E>
-
getSet(String name): SetAttribute<? super X, E>
-
getList(String name, Class<E> elementType): ListAttribute<? super X, E>
-
getList(String name): ListAttribute<? super X, E>
-
getMap(String name, Class<K> keyType, Class<V> valueType): MapAttribute<? super X, K, V>
-
getMap(String name): MapAttribute<? super X, K, V>
-
hasSingleIdAttribute(): boolean
-
hasVersionAttribute(): boolean
-
getIdType(): Type<?>
-
getId(Class<Y> type): SingularAttribute<? super X, Y>
-
getVersion(Class<Y> type): SingularAttribute<? super X, Y>
-
getPersistenceType(): PersistenceType
-
PersistenceType
peut prendre les valeurs suivantes: ENTITY, EMBEDDABLE, MAPPED_SUPERCLASS, BASIC.
-
Attribute<X, Y>
-
getName(): String
-
getPersistentAttributeType(): PersistentAttributeType
-
getDeclaringType(): ManagedType<X>
-
getJavaType(): Class<Y>
-
getJavaMember(): Member
-
isAssociation(): boolean
-
isCollection(): boolean
-
-
SingularAttribute<X, T> → Attribute<X, Y>
-
getType(): Type<T>
-
isId(): boolean
-
isVersion(): boolean
-
isOptional(): boolean
-
-
PluralAttribute<X, T> → Attribute<X, Y>
-
getCollectionType(): CollectionType
-
getElementType(): Type<E>
-
CollectionType peut prendre les valeurs suivantes: COLLECTION, SET, LIST, MAP
-
CollectionAttribute<X, T> → PluralAttribute<X, Y>
-
SetAttribute<X, T> → PluralAttribute<X, Y>
-
ListAttribute<X, T> → PluralAttribute<X, Y>
-
MapAttribute<X, T> → PluralAttribute<X, Y>
PersistentAttributeType
peut prendre les valeurs suivantes: BASIC, EMBEDDED, ONE_TO_ONE, MANY_TO_ONE, MANY_TO_MANY, ONE_TO_MANY, ELEMENT_COLLECTION.