Class MappingMetamodelImpl
- java.lang.Object
-
- org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl
-
- All Implemented Interfaces:
jakarta.persistence.metamodel.Metamodel,Serializable,Metamodel,MappingMetamodel,JpaMetamodel,MappingMetamodelImplementor,MetamodelImplementor
public class MappingMetamodelImpl extends Object implements MappingMetamodelImplementor, MetamodelImplementor, Serializable
Hibernate implementation of the JPAMetamodelcontract. Really more of the mapping model then the domain model, though it does have reference to the `JpaMetamodel` NOTE : we suppress deprecation warnings because at the moment we still implement a deprecated API so have to reference deprecated things- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MappingMetamodelImpl(SessionFactoryImplementor sessionFactory, TypeConfiguration typeConfiguration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> voidaddNamedEntityGraph(String graphName, RootGraphImplementor<T> entityGraph)voidclose()CollectionPersistercollectionPersister(String role)Get the persister object for a collection role.Map<String,CollectionPersister>collectionPersisters()Get all collection persisters as a Map, which collection role as the key and the persister is the value.RootGraph<?>defaultGraph(Class entityJavaType)RootGraph<?>defaultGraph(String entityName)RootGraph<?>defaultGraph(EntityDomainType<?> entityDomainType)RootGraph<?>defaultGraph(EntityPersister entityDescriptor)<X> EmbeddableDomainType<X>embeddable(Class<X> cls)<X> EntityDomainType<X>entity(Class<X> cls)<X> EntityDomainType<X>entity(String entityName)Access to an entity supporting Hibernate's entity-name featureEntityPersisterentityPersister(Class<?> entityClass)Locate the persister for an entity by the entity class.EntityPersisterentityPersister(String entityName)Locate the persister for an entity by the entity-nameMap<String,EntityPersister>entityPersisters()Get all entity persisters as a Map, which entity name its the key and the persister is the value.CollectionPersisterfindCollectionDescriptor(String role)Find a collection mapping descriptor based on its role.CollectionPersisterfindCollectionDescriptor(NavigableRole role)Find a collection mapping descriptor based on its role.EntityPersisterfindEntityDescriptor(Class<?> entityJavaType)Find an entity mapping descriptor based on its Class.EntityPersisterfindEntityDescriptor(String entityName)Find an entity mapping descriptor based on its Hibernate entity-name.<T> RootGraphImplementor<T>findEntityGraphByName(String name)<T> List<RootGraphImplementor<? super T>>findEntityGraphsByJavaType(Class<T> entityClass)<X> EntityDomainType<X>findEntityType(Class<X> cls)Same asJpaMetamodel.entity(java.lang.String)exceptnullis returned rather than throwing an exception<X> ManagedDomainType<X>findManagedType(Class<X> cls)Same asJpaMetamodel.managedType(java.lang.Class<X>)exceptnullis returned rather than throwing an exceptionRootGraph<?>findNamedGraph(String name)List<RootGraph<?>>findRootGraphsForType(Class baseEntityJavaType)List<RootGraph<?>>findRootGraphsForType(String baseEntityName)List<RootGraph<?>>findRootGraphsForType(EntityPersister baseEntityDescriptor)voidfinishInitialization(MetadataImplementor bootModel, BootstrapContext bootstrapContext, SessionFactoryImplementor sessionFactory)voidforEachCollectionDescriptor(Consumer<CollectionPersister> action)Visit the mapping descriptors for all collections defined in the modelvoidforEachEntityDescriptor(Consumer<EntityPersister> action)Visit all entity mapping descriptors defined in the modelvoidforEachNamedGraph(Consumer<RootGraph<?>> action)String[]getAllCollectionRoles()Get the names of all collections known to this MetamodelString[]getAllEntityNames()Get the names of all entities known to this MetamodelMap<String,Map<Class<?>,Enum<?>>>getAllowedEnumLiteralTexts()Returns a map that gives access to the enum literal expressions that can be used in queries.CollectionPersistergetCollectionDescriptor(String role)Get a collection mapping descriptor based on its roleCollectionPersistergetCollectionDescriptor(NavigableRole role)Get a collection mapping descriptor based on its roleSet<String>getCollectionRolesByEntityParticipant(String entityName)Retrieves a set of all the collection roles in which the given entity is a participant, as either an index or an element.Set<jakarta.persistence.metamodel.EmbeddableType<?>>getEmbeddables()EmbeddableValuedModelPartgetEmbeddableValuedModelPart(NavigableRole role)Get an EmbeddableMappingType based on its NavigableRole.Set<jakarta.persistence.metamodel.EntityType<?>>getEntities()EntityPersistergetEntityDescriptor(Class<?> entityJavaType)Get an entity mapping descriptor based on its Class.EntityPersistergetEntityDescriptor(String entityName)Get an entity mapping descriptor based on its Hibernate entity-nameEntityPersistergetEntityDescriptor(NavigableRole name)Get an entity mapping descriptor based on its NavigableRole.Collection<EntityNameResolver>getEntityNameResolvers()Access to the EntityNameResolver instance that Hibernate is configured to use for determining the entity descriptor from an instance of an entity<X> EntityDomainType<X>getHqlEntityReference(String entityName)Specialized handling for resolving entity-name references in an HQL queryString[]getImplementors(String className)Given the name of an entity class, determine all the class and interface names by which it can be referenced in an HQL query.StringgetImportedName(String name)JpaCompliancegetJpaCompliance()JpaMetamodelImplementorgetJpaMetamodel()Set<jakarta.persistence.metamodel.ManagedType<?>>getManagedTypes()SessionFactoryImplementorgetSessionFactory()Access to the SessionFactory that this Metamodel instance is bound to.TypeConfigurationgetTypeConfiguration()TheTypeConfigurationthis metamodel is associated withbooleanisEntityClass(Class<?> entityJavaType)MappingModelExpressible<?>lenientlyResolveMappingExpressible(SqmExpressible<?> sqmExpressible, Function<NavigablePath,TableGroup> tableGroupLocator)EntityPersisterlocateEntityDescriptor(Class<?> byClass)Locate an entity mapping descriptor by Class.EntityPersisterlocateEntityPersister(String byName)Locate the entity persister by name.<X> ManagedDomainType<X>managedType(Class<X> cls)StringqualifyImportableName(String queryName)EntityPersisterresolveEntityDescriptor(EntityDomainType<?> entityDomainType)Given a JPA entity domain type, get the associated Hibernate entity descriptor<X> EntityDomainType<X>resolveHqlEntityReference(String entityName)Specialized handling for resolving entity-name references in an HQL queryMappingModelExpressible<?>resolveMappingExpressible(SqmExpressible<?> sqmExpressible, Function<NavigablePath,TableGroup> tableGroupLocator)todo (6.0) : POC!!! Intended for use in SQM -> SQL translation<T> BindableType<T>resolveQueryParameterType(Class<T> javaClass)Given a Java type, determine the corresponding BindableType to use implicitlyStream<CollectionPersister>streamCollectionDescriptors()Stream<EntityPersister>streamEntityDescriptors()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.metamodel.model.domain.JpaMetamodel
getServiceRegistry
-
Methods inherited from interface org.hibernate.metamodel.MappingMetamodel
locateEntityPersister
-
-
-
-
Constructor Detail
-
MappingMetamodelImpl
public MappingMetamodelImpl(SessionFactoryImplementor sessionFactory, TypeConfiguration typeConfiguration)
-
-
Method Detail
-
getJpaMetamodel
public JpaMetamodelImplementor getJpaMetamodel()
-
finishInitialization
public void finishInitialization(MetadataImplementor bootModel, BootstrapContext bootstrapContext, SessionFactoryImplementor sessionFactory)
-
getEntityNameResolvers
public Collection<EntityNameResolver> getEntityNameResolvers()
Description copied from interface:MappingMetamodelImplementorAccess to the EntityNameResolver instance that Hibernate is configured to use for determining the entity descriptor from an instance of an entity- Specified by:
getEntityNameResolversin interfaceMappingMetamodelImplementor- Specified by:
getEntityNameResolversin interfaceMetamodelImplementor
-
getTypeConfiguration
public TypeConfiguration getTypeConfiguration()
Description copied from interface:MappingMetamodelTheTypeConfigurationthis metamodel is associated with- Specified by:
getTypeConfigurationin interfaceJpaMetamodel- Specified by:
getTypeConfigurationin interfaceMappingMetamodel
-
forEachEntityDescriptor
public void forEachEntityDescriptor(Consumer<EntityPersister> action)
Description copied from interface:MappingMetamodelVisit all entity mapping descriptors defined in the model- Specified by:
forEachEntityDescriptorin interfaceMappingMetamodel
-
streamEntityDescriptors
public Stream<EntityPersister> streamEntityDescriptors()
- Specified by:
streamEntityDescriptorsin interfaceMappingMetamodel
-
resolveEntityDescriptor
public EntityPersister resolveEntityDescriptor(EntityDomainType<?> entityDomainType)
Description copied from interface:MappingMetamodelGiven a JPA entity domain type, get the associated Hibernate entity descriptor- Specified by:
resolveEntityDescriptorin interfaceMappingMetamodel
-
getEntityDescriptor
public EntityPersister getEntityDescriptor(String entityName)
Description copied from interface:MappingMetamodelGet an entity mapping descriptor based on its Hibernate entity-name- Specified by:
getEntityDescriptorin interfaceMappingMetamodel- See Also:
MappingMetamodel.findEntityDescriptor(java.lang.String)
-
getEntityDescriptor
public EntityPersister getEntityDescriptor(NavigableRole name)
Description copied from interface:MappingMetamodelGet an entity mapping descriptor based on its NavigableRole.- Specified by:
getEntityDescriptorin interfaceMappingMetamodel- See Also:
MappingMetamodel.findEntityDescriptor(java.lang.String)
-
getEmbeddableValuedModelPart
public EmbeddableValuedModelPart getEmbeddableValuedModelPart(NavigableRole role)
Description copied from interface:MappingMetamodelGet an EmbeddableMappingType based on its NavigableRole.- Specified by:
getEmbeddableValuedModelPartin interfaceMappingMetamodel- See Also:
MappingMetamodel.findEntityDescriptor(java.lang.String)
-
findEntityDescriptor
public EntityPersister findEntityDescriptor(String entityName)
Description copied from interface:MappingMetamodelFind an entity mapping descriptor based on its Hibernate entity-name.- Specified by:
findEntityDescriptorin interfaceMappingMetamodel
-
findEntityDescriptor
public EntityPersister findEntityDescriptor(Class<?> entityJavaType)
Description copied from interface:MappingMetamodelFind an entity mapping descriptor based on its Class.- Specified by:
findEntityDescriptorin interfaceMappingMetamodel
-
isEntityClass
public boolean isEntityClass(Class<?> entityJavaType)
- Specified by:
isEntityClassin interfaceMappingMetamodel
-
getSessionFactory
public SessionFactoryImplementor getSessionFactory()
Description copied from interface:MetamodelAccess to the SessionFactory that this Metamodel instance is bound to.- Specified by:
getSessionFactoryin interfaceMetamodel- Specified by:
getSessionFactoryin interfaceMetamodelImplementor- Returns:
- The SessionFactory
-
getEntityDescriptor
public EntityPersister getEntityDescriptor(Class<?> entityJavaType)
Description copied from interface:MappingMetamodelGet an entity mapping descriptor based on its Class.- Specified by:
getEntityDescriptorin interfaceMappingMetamodel- See Also:
MappingMetamodel.findEntityDescriptor(java.lang.String)
-
locateEntityDescriptor
public EntityPersister locateEntityDescriptor(Class<?> byClass)
Description copied from interface:MappingMetamodelLocate an entity mapping descriptor by Class. The passed Class might refer to either the entity Class directly, or it might name a proxy interface for the entity. This method accounts for both, preferring the direct entity name.- Specified by:
locateEntityDescriptorin interfaceMappingMetamodel
-
entity
public <X> EntityDomainType<X> entity(Class<X> cls)
- Specified by:
entityin interfaceJpaMetamodel- Specified by:
entityin interfacejakarta.persistence.metamodel.Metamodel
-
managedType
public <X> ManagedDomainType<X> managedType(Class<X> cls)
- Specified by:
managedTypein interfaceJpaMetamodel- Specified by:
managedTypein interfacejakarta.persistence.metamodel.Metamodel
-
embeddable
public <X> EmbeddableDomainType<X> embeddable(Class<X> cls)
- Specified by:
embeddablein interfaceJpaMetamodel- Specified by:
embeddablein interfacejakarta.persistence.metamodel.Metamodel
-
getManagedTypes
public Set<jakarta.persistence.metamodel.ManagedType<?>> getManagedTypes()
- Specified by:
getManagedTypesin interfaceJpaMetamodel- Specified by:
getManagedTypesin interfacejakarta.persistence.metamodel.Metamodel
-
getEntities
public Set<jakarta.persistence.metamodel.EntityType<?>> getEntities()
- Specified by:
getEntitiesin interfaceJpaMetamodel- Specified by:
getEntitiesin interfacejakarta.persistence.metamodel.Metamodel
-
getEmbeddables
public Set<jakarta.persistence.metamodel.EmbeddableType<?>> getEmbeddables()
- Specified by:
getEmbeddablesin interfaceJpaMetamodel- Specified by:
getEmbeddablesin interfacejakarta.persistence.metamodel.Metamodel
-
entity
public <X> EntityDomainType<X> entity(String entityName)
Description copied from interface:JpaMetamodelAccess to an entity supporting Hibernate's entity-name feature- Specified by:
entityin interfaceJpaMetamodel
-
getHqlEntityReference
public <X> EntityDomainType<X> getHqlEntityReference(String entityName)
Description copied from interface:JpaMetamodelSpecialized handling for resolving entity-name references in an HQL query- Specified by:
getHqlEntityReferencein interfaceJpaMetamodel
-
resolveHqlEntityReference
public <X> EntityDomainType<X> resolveHqlEntityReference(String entityName)
Description copied from interface:JpaMetamodelSpecialized handling for resolving entity-name references in an HQL query- Specified by:
resolveHqlEntityReferencein interfaceJpaMetamodel
-
findManagedType
public <X> ManagedDomainType<X> findManagedType(Class<X> cls)
Description copied from interface:JpaMetamodelSame asJpaMetamodel.managedType(java.lang.Class<X>)exceptnullis returned rather than throwing an exception- Specified by:
findManagedTypein interfaceJpaMetamodel
-
findEntityType
public <X> EntityDomainType<X> findEntityType(Class<X> cls)
Description copied from interface:JpaMetamodelSame asJpaMetamodel.entity(java.lang.String)exceptnullis returned rather than throwing an exception- Specified by:
findEntityTypein interfaceJpaMetamodel
-
qualifyImportableName
public String qualifyImportableName(String queryName)
- Specified by:
qualifyImportableNamein interfaceJpaMetamodel
-
getAllowedEnumLiteralTexts
public Map<String,Map<Class<?>,Enum<?>>> getAllowedEnumLiteralTexts()
Description copied from interface:JpaMetamodelReturns a map that gives access to the enum literal expressions that can be used in queries. The key is the short-hand enum literal. The value is a map, from enum class to the actual enum value. This is needed for parsing short-hand enum literals that don't use FQNs.- Specified by:
getAllowedEnumLiteralTextsin interfaceJpaMetamodel
-
getImplementors
public String[] getImplementors(String className) throws MappingException
Description copied from interface:MetamodelGiven the name of an entity class, determine all the class and interface names by which it can be referenced in an HQL query.- Specified by:
getImplementorsin interfaceMetamodel- Parameters:
className- The name of the entity class- Returns:
- the names of all persistent (mapped) classes that extend or implement the given class or interface, accounting for implicit/explicit polymorphism settings and excluding mapped subclasses/joined-subclasses of other classes in the result.
- Throws:
MappingException
-
entityPersisters
public Map<String,EntityPersister> entityPersisters()
Description copied from interface:MetamodelImplementorGet all entity persisters as a Map, which entity name its the key and the persister is the value.- Specified by:
entityPersistersin interfaceMetamodelImplementor- Returns:
- The Map contains all entity persisters.
-
collectionPersister
public CollectionPersister collectionPersister(String role)
Description copied from interface:MetamodelImplementorGet the persister object for a collection role.- Specified by:
collectionPersisterin interfaceMetamodelImplementor- Parameters:
role- The role of the collection for which to retrieve the persister.- Returns:
- The persister
-
collectionPersisters
public Map<String,CollectionPersister> collectionPersisters()
Description copied from interface:MetamodelImplementorGet all collection persisters as a Map, which collection role as the key and the persister is the value.- Specified by:
collectionPersistersin interfaceMetamodelImplementor- Returns:
- The Map contains all collection persisters.
-
entityPersister
public EntityPersister entityPersister(Class<?> entityClass)
Description copied from interface:MetamodelImplementorLocate the persister for an entity by the entity class.- Specified by:
entityPersisterin interfaceMetamodelImplementor- Parameters:
entityClass- The entity class- Returns:
- The entity persister
-
entityPersister
public EntityPersister entityPersister(String entityName) throws MappingException
Description copied from interface:MetamodelImplementorLocate the persister for an entity by the entity-name- Specified by:
entityPersisterin interfaceMetamodelImplementor- Parameters:
entityName- The name of the entity for which to retrieve the persister.- Returns:
- The persister
- Throws:
MappingException- Indicates persister could not be found with that name.
-
locateEntityPersister
public EntityPersister locateEntityPersister(String byName)
Description copied from interface:MappingMetamodelLocate the entity persister by name.- Specified by:
locateEntityPersisterin interfaceMappingMetamodel- Returns:
- The located EntityPersister, never
null
-
getImportedName
public String getImportedName(String name)
- Specified by:
getImportedNamein interfaceMappingMetamodel
-
forEachCollectionDescriptor
public void forEachCollectionDescriptor(Consumer<CollectionPersister> action)
Description copied from interface:MappingMetamodelVisit the mapping descriptors for all collections defined in the model- Specified by:
forEachCollectionDescriptorin interfaceMappingMetamodel
-
streamCollectionDescriptors
public Stream<CollectionPersister> streamCollectionDescriptors()
- Specified by:
streamCollectionDescriptorsin interfaceMappingMetamodel
-
getCollectionDescriptor
public CollectionPersister getCollectionDescriptor(String role)
Description copied from interface:MappingMetamodelGet a collection mapping descriptor based on its role- Specified by:
getCollectionDescriptorin interfaceMappingMetamodel- See Also:
MappingMetamodel.findCollectionDescriptor(org.hibernate.metamodel.model.domain.NavigableRole)
-
getCollectionDescriptor
public CollectionPersister getCollectionDescriptor(NavigableRole role)
Description copied from interface:MappingMetamodelGet a collection mapping descriptor based on its role- Specified by:
getCollectionDescriptorin interfaceMappingMetamodel- See Also:
MappingMetamodel.findCollectionDescriptor(org.hibernate.metamodel.model.domain.NavigableRole)
-
findCollectionDescriptor
public CollectionPersister findCollectionDescriptor(NavigableRole role)
Description copied from interface:MappingMetamodelFind a collection mapping descriptor based on its role. Returnsnullif the role does not refer to a collection- Specified by:
findCollectionDescriptorin interfaceMappingMetamodel- See Also:
MappingMetamodel.findCollectionDescriptor(org.hibernate.metamodel.model.domain.NavigableRole)
-
findCollectionDescriptor
public CollectionPersister findCollectionDescriptor(String role)
Description copied from interface:MappingMetamodelFind a collection mapping descriptor based on its role. Returnsnullif the role does not refer to a collection- Specified by:
findCollectionDescriptorin interfaceMappingMetamodel- See Also:
MappingMetamodel.findCollectionDescriptor(org.hibernate.metamodel.model.domain.NavigableRole)
-
getCollectionRolesByEntityParticipant
public Set<String> getCollectionRolesByEntityParticipant(String entityName)
Description copied from interface:MappingMetamodelImplementorRetrieves a set of all the collection roles in which the given entity is a participant, as either an index or an element.- Specified by:
getCollectionRolesByEntityParticipantin interfaceMappingMetamodelImplementor- Specified by:
getCollectionRolesByEntityParticipantin interfaceMetamodelImplementor- Parameters:
entityName- The entity name for which to get the collection roles.- Returns:
- set of all the collection roles in which the given entityName participates.
-
getAllEntityNames
public String[] getAllEntityNames()
Description copied from interface:MetamodelImplementorGet the names of all entities known to this Metamodel- Specified by:
getAllEntityNamesin interfaceMetamodelImplementor- Returns:
- All the entity names
-
getAllCollectionRoles
public String[] getAllCollectionRoles()
Description copied from interface:MetamodelImplementorGet the names of all collections known to this Metamodel- Specified by:
getAllCollectionRolesin interfaceMetamodelImplementor- Returns:
- All the entity names
-
addNamedEntityGraph
public <T> void addNamedEntityGraph(String graphName, RootGraphImplementor<T> entityGraph)
- Specified by:
addNamedEntityGraphin interfaceJpaMetamodel- Specified by:
addNamedEntityGraphin interfaceMappingMetamodel
-
findEntityGraphByName
public <T> RootGraphImplementor<T> findEntityGraphByName(String name)
- Specified by:
findEntityGraphByNamein interfaceJpaMetamodel
-
findEntityGraphsByJavaType
public <T> List<RootGraphImplementor<? super T>> findEntityGraphsByJavaType(Class<T> entityClass)
- Specified by:
findEntityGraphsByJavaTypein interfaceJpaMetamodel
-
getJpaCompliance
public JpaCompliance getJpaCompliance()
- Specified by:
getJpaCompliancein interfaceJpaMetamodel
-
findNamedGraph
public RootGraph<?> findNamedGraph(String name)
- Specified by:
findNamedGraphin interfaceMappingMetamodel
-
forEachNamedGraph
public void forEachNamedGraph(Consumer<RootGraph<?>> action)
- Specified by:
forEachNamedGraphin interfaceMappingMetamodel
-
defaultGraph
public RootGraph<?> defaultGraph(String entityName)
- Specified by:
defaultGraphin interfaceMappingMetamodel
-
defaultGraph
public RootGraph<?> defaultGraph(Class entityJavaType)
- Specified by:
defaultGraphin interfaceMappingMetamodel
-
defaultGraph
public RootGraph<?> defaultGraph(EntityPersister entityDescriptor)
- Specified by:
defaultGraphin interfaceMappingMetamodel
-
defaultGraph
public RootGraph<?> defaultGraph(EntityDomainType<?> entityDomainType)
- Specified by:
defaultGraphin interfaceMappingMetamodel
-
findRootGraphsForType
public List<RootGraph<?>> findRootGraphsForType(Class baseEntityJavaType)
- Specified by:
findRootGraphsForTypein interfaceMappingMetamodel
-
findRootGraphsForType
public List<RootGraph<?>> findRootGraphsForType(String baseEntityName)
- Specified by:
findRootGraphsForTypein interfaceMappingMetamodel
-
findRootGraphsForType
public List<RootGraph<?>> findRootGraphsForType(EntityPersister baseEntityDescriptor)
- Specified by:
findRootGraphsForTypein interfaceMappingMetamodel
-
close
public void close()
- Specified by:
closein interfaceMetamodelImplementor
-
lenientlyResolveMappingExpressible
public MappingModelExpressible<?> lenientlyResolveMappingExpressible(SqmExpressible<?> sqmExpressible, Function<NavigablePath,TableGroup> tableGroupLocator)
- Specified by:
lenientlyResolveMappingExpressiblein interfaceMappingMetamodel
-
resolveMappingExpressible
public MappingModelExpressible<?> resolveMappingExpressible(SqmExpressible<?> sqmExpressible, Function<NavigablePath,TableGroup> tableGroupLocator)
Description copied from interface:MappingMetamodeltodo (6.0) : POC!!! Intended for use in SQM -> SQL translation- Specified by:
resolveMappingExpressiblein interfaceMappingMetamodel
-
resolveQueryParameterType
public <T> BindableType<T> resolveQueryParameterType(Class<T> javaClass)
Description copied from interface:MappingMetamodelGiven a Java type, determine the corresponding BindableType to use implicitly- Specified by:
resolveQueryParameterTypein interfaceMappingMetamodel
-
-