Package org.hibernate.engine.spi
Class SessionFactoryDelegatingImpl
- java.lang.Object
-
- org.hibernate.engine.spi.SessionFactoryDelegatingImpl
-
- All Implemented Interfaces:
jakarta.persistence.EntityManagerFactory
,Closeable
,Serializable
,AutoCloseable
,Referenceable
,Mapping
,SessionFactoryImplementor
,QueryParameterBindingTypeResolver
,SqmCreationContext
,SessionFactory
,SqlAstCreationContext
public class SessionFactoryDelegatingImpl extends Object implements SessionFactoryImplementor, SessionFactory
Base delegating implementation of theSessionFactory
andSessionFactoryImplementor
contracts for intended for easier implementation ofSessionFactory
.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.hibernate.SessionFactory
SessionFactory.TransactionManagementException
-
Nested classes/interfaces inherited from interface org.hibernate.engine.spi.SessionFactoryImplementor
SessionFactoryImplementor.DeserializationResolver<T extends SessionFactoryImplementor>
-
-
Constructor Summary
Constructors Constructor Description SessionFactoryDelegatingImpl(SessionFactoryImplementor delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description <T> void
addNamedEntityGraph(String graphName, jakarta.persistence.EntityGraph<T> entityGraph)
void
addNamedQuery(String name, jakarta.persistence.Query query)
void
addObserver(SessionFactoryObserver observer)
String
bestGuessEntityName(Object object)
The best guess entity name for an entity not in an associationvoid
close()
Destroy thisSessionFactory
and release all its resources, including caches and connection pools.boolean
containsFetchProfileDefinition(String name)
Determine if this session factory contains a fetch profile definition registered under the given name.jakarta.persistence.EntityManager
createEntityManager()
jakarta.persistence.EntityManager
createEntityManager(jakarta.persistence.SynchronizationType synchronizationType)
jakarta.persistence.EntityManager
createEntityManager(jakarta.persistence.SynchronizationType synchronizationType, Map map)
jakarta.persistence.EntityManager
createEntityManager(Map map)
protected SessionFactoryImplementor
delegate()
RootGraphImplementor<?>
findEntityGraphByName(String name)
<T> List<jakarta.persistence.EntityGraph<? super T>>
findEntityGraphsByType(Class<T> entityClass)
Return allEntityGraph
s registered for the given entity type.CacheImplementor
getCache()
Obtain direct access to the underlying cache regions.Set<String>
getCollectionRolesByEntityParticipant(String entityName)
Deprecated.HibernateCriteriaBuilder
getCriteriaBuilder()
Session
getCurrentSession()
Obtains the current session, an instance ofSession
implicitly associated with some context.CurrentTenantIdentifierResolver
getCurrentTenantIdentifierResolver()
CustomEntityDirtinessStrategy
getCustomEntityDirtinessStrategy()
Set<String>
getDefinedFilterNames()
Obtain the set of names of alldefined filters
.SessionFactoryImplementor.DeserializationResolver
getDeserializationResolver()
EntityNotFoundDelegate
getEntityNotFoundDelegate()
EventEngine
getEventEngine()
Get the EventEngine associated with this SessionFactoryFastSessionServices
getFastSessionServices()
FetchProfile
getFetchProfile(String name)
Retrieve fetch profile by name.FilterDefinition
getFilterDefinition(String filterName)
Obtain the definition of a filter by name.IdentifierGenerator
getIdentifierGenerator(String rootEntityName)
Get the identifier generator for the hierarchyString
getIdentifierPropertyName(String className)
Type
getIdentifierType(String className)
JdbcServices
getJdbcServices()
Get the JdbcServices.JpaMetamodelImplementor
getJpaMetamodel()
Access to the domain model metadataInteger
getMaximumFetchDepth()
When creatingFetch
references, defines a limit to how deep we should join for fetches.MetamodelImplementor
getMetamodel()
Deprecated.String
getName()
Access to the name (if one) assigned to the SessionFactoryjakarta.persistence.PersistenceUnitUtil
getPersistenceUnitUtil()
Map<String,Object>
getProperties()
QueryEngine
getQueryEngine()
Reference
getReference()
Type
getReferencedPropertyType(String className, String propertyName)
RuntimeMetamodelsImplementor
getRuntimeMetamodels()
ServiceRegistryImplementor
getServiceRegistry()
Access to the ServiceRegistry for this SessionFactory.SessionFactoryOptions
getSessionFactoryOptions()
Get the special options used to build the factory.SqlStringGenerationContext
getSqlStringGenerationContext()
StatisticsImplementor
getStatistics()
Retrieve the statistics for this factory.TypeConfiguration
getTypeConfiguration()
String
getUuid()
Get the UUID for this SessionFactory.WrapperOptions
getWrapperOptions()
boolean
isClosed()
Is this factory already closed?boolean
isOpen()
Session
openSession()
Open aSession
.StatelessSession
openStatelessSession()
Open a new stateless session.StatelessSession
openStatelessSession(Connection connection)
Open a new stateless session, utilizing the specified JDBCConnection
.Session
openTemporarySession()
Get a non-transactional "current" session (used by hibernate-envers)<T> BindableType<T>
resolveParameterBindType(Class<T> clazz)
<T> BindableType<? extends T>
resolveParameterBindType(T bindValue)
<T> T
unwrap(Class<T> cls)
SessionBuilderImplementor
withOptions()
Obtain a session builder for creating newSession
s with certain customized options.StatelessSessionBuilder
withStatelessOptions()
Obtain aStatelessSession
builder.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.SessionFactory
fromSession, fromTransaction, inSession, inTransaction
-
Methods inherited from interface org.hibernate.engine.spi.SessionFactoryImplementor
getMappingMetamodel, getSessionFactory
-
Methods inherited from interface org.hibernate.query.sqm.spi.SqmCreationContext
getNodeBuilder
-
-
-
-
Constructor Detail
-
SessionFactoryDelegatingImpl
public SessionFactoryDelegatingImpl(SessionFactoryImplementor delegate)
-
-
Method Detail
-
delegate
protected SessionFactoryImplementor delegate()
-
getSessionFactoryOptions
public SessionFactoryOptions getSessionFactoryOptions()
Description copied from interface:SessionFactory
Get the special options used to build the factory.- Specified by:
getSessionFactoryOptions
in interfaceSessionFactory
- Returns:
- The special options used to build the factory.
-
withOptions
public SessionBuilderImplementor withOptions()
Description copied from interface:SessionFactory
Obtain a session builder for creating newSession
s with certain customized options.- Specified by:
withOptions
in interfaceSessionFactory
- Specified by:
withOptions
in interfaceSessionFactoryImplementor
- Returns:
- The session builder
-
openSession
public Session openSession() throws HibernateException
Description copied from interface:SessionFactory
Open aSession
. Any JDBCconnection
will be obtained lazily from theConnectionProvider
as needed to perform requested work.- Specified by:
openSession
in interfaceSessionFactory
- Returns:
- The created session.
- Throws:
HibernateException
- Indicates a problem opening the session; pretty rare here.
-
getCurrentSession
public Session getCurrentSession() throws HibernateException
Description copied from interface:SessionFactory
Obtains the current session, an instance ofSession
implicitly associated with some context. For example, the session might be associated with the current thread, or with the current JTA transaction.The context used for scoping the current session (that is, the definition of what precisely "current" means here) is determined by an implementation of
CurrentSessionContext
. An implementation may be selected using the configuration property "hibernate.current_session_context_class".If no
CurrentSessionContext
is explicitly configured, but JTA is configured, thenJTASessionContext
is used.- Specified by:
getCurrentSession
in interfaceSessionFactory
- Returns:
- The current session.
- Throws:
HibernateException
- Indicates an issue locating a suitable current session.
-
withStatelessOptions
public StatelessSessionBuilder withStatelessOptions()
Description copied from interface:SessionFactory
Obtain aStatelessSession
builder.- Specified by:
withStatelessOptions
in interfaceSessionFactory
- Returns:
- The stateless session builder
-
openStatelessSession
public StatelessSession openStatelessSession()
Description copied from interface:SessionFactory
Open a new stateless session.- Specified by:
openStatelessSession
in interfaceSessionFactory
- Returns:
- The created stateless session.
-
openStatelessSession
public StatelessSession openStatelessSession(Connection connection)
Description copied from interface:SessionFactory
Open a new stateless session, utilizing the specified JDBCConnection
.- Specified by:
openStatelessSession
in interfaceSessionFactory
- Parameters:
connection
- Connection provided by the application.- Returns:
- The created stateless session.
-
getStatistics
public StatisticsImplementor getStatistics()
Description copied from interface:SessionFactory
Retrieve the statistics for this factory.- Specified by:
getStatistics
in interfaceSessionFactory
- Specified by:
getStatistics
in interfaceSessionFactoryImplementor
- Returns:
- The statistics.
-
getRuntimeMetamodels
public RuntimeMetamodelsImplementor getRuntimeMetamodels()
- Specified by:
getRuntimeMetamodels
in interfaceSessionFactoryImplementor
-
getEventEngine
public EventEngine getEventEngine()
Description copied from interface:SessionFactoryImplementor
Get the EventEngine associated with this SessionFactory- Specified by:
getEventEngine
in interfaceSessionFactoryImplementor
-
close
public void close() throws HibernateException
Description copied from interface:SessionFactory
Destroy thisSessionFactory
and release all its resources, including caches and connection pools. It is the responsibility of the application to ensure that there are no open sessions before calling this method as the impact on those sessions is indeterminate. No-ops if already closed.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfacejakarta.persistence.EntityManagerFactory
- Specified by:
close
in interfaceSessionFactory
- Throws:
HibernateException
- Indicates an issue closing the factory.
-
isClosed
public boolean isClosed()
Description copied from interface:SessionFactory
Is this factory already closed?- Specified by:
isClosed
in interfaceSessionFactory
- Returns:
- True if this factory is already closed; false otherwise.
-
getCache
public CacheImplementor getCache()
Description copied from interface:SessionFactory
Obtain direct access to the underlying cache regions.- Specified by:
getCache
in interfacejakarta.persistence.EntityManagerFactory
- Specified by:
getCache
in interfaceSessionFactory
- Specified by:
getCache
in interfaceSessionFactoryImplementor
- Returns:
- The direct cache access API.
-
getPersistenceUnitUtil
public jakarta.persistence.PersistenceUnitUtil getPersistenceUnitUtil()
- Specified by:
getPersistenceUnitUtil
in interfacejakarta.persistence.EntityManagerFactory
-
addNamedQuery
public void addNamedQuery(String name, jakarta.persistence.Query query)
- Specified by:
addNamedQuery
in interfacejakarta.persistence.EntityManagerFactory
-
unwrap
public <T> T unwrap(Class<T> cls)
- Specified by:
unwrap
in interfacejakarta.persistence.EntityManagerFactory
-
addNamedEntityGraph
public <T> void addNamedEntityGraph(String graphName, jakarta.persistence.EntityGraph<T> entityGraph)
- Specified by:
addNamedEntityGraph
in interfacejakarta.persistence.EntityManagerFactory
-
getDefinedFilterNames
public Set<String> getDefinedFilterNames()
Description copied from interface:SessionFactory
Obtain the set of names of alldefined filters
.- Specified by:
getDefinedFilterNames
in interfaceSessionFactory
- Returns:
- The set of filter names.
-
getFilterDefinition
public FilterDefinition getFilterDefinition(String filterName) throws HibernateException
Description copied from interface:SessionFactory
Obtain the definition of a filter by name.- Specified by:
getFilterDefinition
in interfaceSessionFactory
- Parameters:
filterName
- The name of the filter for which to obtain the definition.- Returns:
- The filter definition.
- Throws:
HibernateException
- If no filter defined with the given name.
-
containsFetchProfileDefinition
public boolean containsFetchProfileDefinition(String name)
Description copied from interface:SessionFactory
Determine if this session factory contains a fetch profile definition registered under the given name.- Specified by:
containsFetchProfileDefinition
in interfaceSessionFactory
- Parameters:
name
- The name to check- Returns:
- True if there is such a fetch profile; false otherwise.
-
getIdentifierGenerator
public IdentifierGenerator getIdentifierGenerator(String rootEntityName)
Description copied from interface:SessionFactoryImplementor
Get the identifier generator for the hierarchy- Specified by:
getIdentifierGenerator
in interfaceSessionFactoryImplementor
-
getProperties
public Map<String,Object> getProperties()
- Specified by:
getProperties
in interfacejakarta.persistence.EntityManagerFactory
-
getJdbcServices
public JdbcServices getJdbcServices()
Description copied from interface:SessionFactoryImplementor
Get the JdbcServices.- Specified by:
getJdbcServices
in interfaceSessionFactoryImplementor
- Returns:
- the JdbcServices
-
getSqlStringGenerationContext
public SqlStringGenerationContext getSqlStringGenerationContext()
- Specified by:
getSqlStringGenerationContext
in interfaceSessionFactoryImplementor
-
findEntityGraphByName
public RootGraphImplementor<?> findEntityGraphByName(String name)
- Specified by:
findEntityGraphByName
in interfaceSessionFactoryImplementor
-
bestGuessEntityName
public String bestGuessEntityName(Object object)
Description copied from interface:SessionFactoryImplementor
The best guess entity name for an entity not in an association- Specified by:
bestGuessEntityName
in interfaceSessionFactoryImplementor
-
openTemporarySession
public Session openTemporarySession() throws HibernateException
Description copied from interface:SessionFactoryImplementor
Get a non-transactional "current" session (used by hibernate-envers)- Specified by:
openTemporarySession
in interfaceSessionFactoryImplementor
- Throws:
HibernateException
-
getCollectionRolesByEntityParticipant
@Deprecated public Set<String> getCollectionRolesByEntityParticipant(String entityName)
Deprecated.
-
getEntityNotFoundDelegate
public EntityNotFoundDelegate getEntityNotFoundDelegate()
- Specified by:
getEntityNotFoundDelegate
in interfaceSessionFactoryImplementor
-
getFetchProfile
public FetchProfile getFetchProfile(String name)
Description copied from interface:SessionFactoryImplementor
Retrieve fetch profile by name.- Specified by:
getFetchProfile
in interfaceSessionFactoryImplementor
- Parameters:
name
- The name of the profile to retrieve.- Returns:
- The profile definition
-
getJpaMetamodel
public JpaMetamodelImplementor getJpaMetamodel()
Description copied from interface:SqmCreationContext
Access to the domain model metadata- Specified by:
getJpaMetamodel
in interfaceSqmCreationContext
-
getServiceRegistry
public ServiceRegistryImplementor getServiceRegistry()
Description copied from interface:SessionFactoryImplementor
Access to the ServiceRegistry for this SessionFactory.- Specified by:
getServiceRegistry
in interfaceSessionFactoryImplementor
- Specified by:
getServiceRegistry
in interfaceSqlAstCreationContext
- Specified by:
getServiceRegistry
in interfaceSqmCreationContext
- Returns:
- The factory's ServiceRegistry
-
getMaximumFetchDepth
public Integer getMaximumFetchDepth()
Description copied from interface:SqlAstCreationContext
When creatingFetch
references, defines a limit to how deep we should join for fetches.- Specified by:
getMaximumFetchDepth
in interfaceSqlAstCreationContext
-
addObserver
public void addObserver(SessionFactoryObserver observer)
- Specified by:
addObserver
in interfaceSessionFactoryImplementor
-
getCustomEntityDirtinessStrategy
public CustomEntityDirtinessStrategy getCustomEntityDirtinessStrategy()
- Specified by:
getCustomEntityDirtinessStrategy
in interfaceSessionFactoryImplementor
-
getCurrentTenantIdentifierResolver
public CurrentTenantIdentifierResolver getCurrentTenantIdentifierResolver()
- Specified by:
getCurrentTenantIdentifierResolver
in interfaceSessionFactoryImplementor
-
getFastSessionServices
public FastSessionServices getFastSessionServices()
- Specified by:
getFastSessionServices
in interfaceSessionFactoryImplementor
- Returns:
- the FastSessionServices instance associated with this SessionFactory
-
getDeserializationResolver
public SessionFactoryImplementor.DeserializationResolver getDeserializationResolver()
- Specified by:
getDeserializationResolver
in interfaceSessionFactoryImplementor
-
getIdentifierType
public Type getIdentifierType(String className) throws MappingException
- Specified by:
getIdentifierType
in interfaceMapping
- Throws:
MappingException
-
getIdentifierPropertyName
public String getIdentifierPropertyName(String className) throws MappingException
- Specified by:
getIdentifierPropertyName
in interfaceMapping
- Throws:
MappingException
-
getReferencedPropertyType
public Type getReferencedPropertyType(String className, String propertyName) throws MappingException
- Specified by:
getReferencedPropertyType
in interfaceMapping
- Throws:
MappingException
-
getUuid
public String getUuid()
Description copied from interface:SessionFactoryImplementor
Get the UUID for this SessionFactory.The value is generated as a
UUID
, but kept as a String.- Specified by:
getUuid
in interfaceSessionFactoryImplementor
- Returns:
- The UUID for this SessionFactory.
- See Also:
SessionFactoryRegistry.getSessionFactory(java.lang.String)
-
getName
public String getName()
Description copied from interface:SessionFactoryImplementor
Access to the name (if one) assigned to the SessionFactory- Specified by:
getName
in interfaceSessionFactoryImplementor
- Returns:
- The name for the SessionFactory
-
getTypeConfiguration
public TypeConfiguration getTypeConfiguration()
- Specified by:
getTypeConfiguration
in interfaceQueryParameterBindingTypeResolver
- Specified by:
getTypeConfiguration
in interfaceSessionFactoryImplementor
-
getQueryEngine
public QueryEngine getQueryEngine()
- Specified by:
getQueryEngine
in interfaceSessionFactoryImplementor
- Specified by:
getQueryEngine
in interfaceSqmCreationContext
-
getReference
public Reference getReference() throws NamingException
- Specified by:
getReference
in interfaceReferenceable
- Throws:
NamingException
-
createEntityManager
public jakarta.persistence.EntityManager createEntityManager()
- Specified by:
createEntityManager
in interfacejakarta.persistence.EntityManagerFactory
-
createEntityManager
public jakarta.persistence.EntityManager createEntityManager(Map map)
- Specified by:
createEntityManager
in interfacejakarta.persistence.EntityManagerFactory
-
createEntityManager
public jakarta.persistence.EntityManager createEntityManager(jakarta.persistence.SynchronizationType synchronizationType)
- Specified by:
createEntityManager
in interfacejakarta.persistence.EntityManagerFactory
-
createEntityManager
public jakarta.persistence.EntityManager createEntityManager(jakarta.persistence.SynchronizationType synchronizationType, Map map)
- Specified by:
createEntityManager
in interfacejakarta.persistence.EntityManagerFactory
-
getCriteriaBuilder
public HibernateCriteriaBuilder getCriteriaBuilder()
- Specified by:
getCriteriaBuilder
in interfacejakarta.persistence.EntityManagerFactory
- Specified by:
getCriteriaBuilder
in interfaceSessionFactoryImplementor
-
getMetamodel
@Deprecated public MetamodelImplementor getMetamodel()
Deprecated.- Specified by:
getMetamodel
in interfacejakarta.persistence.EntityManagerFactory
- Specified by:
getMetamodel
in interfaceSessionFactoryImplementor
-
isOpen
public boolean isOpen()
- Specified by:
isOpen
in interfacejakarta.persistence.EntityManagerFactory
-
resolveParameterBindType
public <T> BindableType<? extends T> resolveParameterBindType(T bindValue)
- Specified by:
resolveParameterBindType
in interfaceQueryParameterBindingTypeResolver
-
resolveParameterBindType
public <T> BindableType<T> resolveParameterBindType(Class<T> clazz)
- Specified by:
resolveParameterBindType
in interfaceQueryParameterBindingTypeResolver
-
getWrapperOptions
public WrapperOptions getWrapperOptions()
- Specified by:
getWrapperOptions
in interfaceSessionFactoryImplementor
-
findEntityGraphsByType
public <T> List<jakarta.persistence.EntityGraph<? super T>> findEntityGraphsByType(Class<T> entityClass)
Description copied from interface:SessionFactory
Return allEntityGraph
s registered for the given entity type.- Specified by:
findEntityGraphsByType
in interfaceSessionFactory
- See Also:
EntityManagerFactory.addNamedEntityGraph(java.lang.String, jakarta.persistence.EntityGraph<T>)
-
-