Package org.hibernate.engine.spi
Class SessionFactoryDelegatingImpl
java.lang.Object
org.hibernate.engine.spi.SessionFactoryDelegatingImpl
- All Implemented Interfaces:
EntityManagerFactory
,Closeable
,Serializable
,AutoCloseable
,Referenceable
,Mapping
,SessionFactoryImplementor
,QueryParameterBindingTypeResolver
,SqmCreationContext
,SessionFactory
,SqlAstCreationContext
public class SessionFactoryDelegatingImpl
extends Object
implements SessionFactoryImplementor, SessionFactory
Base delegating implementation of the
SessionFactory
and
SessionFactoryImplementor
contracts for intended for easier
implementation of SessionFactory
.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.hibernate.engine.spi.SessionFactoryImplementor
SessionFactoryImplementor.DeserializationResolver<T extends SessionFactoryImplementor>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> void
addNamedEntityGraph
(String graphName, EntityGraph<T> entityGraph) void
addNamedQuery
(String name, Query query) void
addObserver
(SessionFactoryObserver observer) 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
Determine if there is a fetch profile definition registered under the given name.createEntityManager
(SynchronizationType synchronizationType) createEntityManager
(SynchronizationType synchronizationType, Map map) createEntityManager
(Map map) protected SessionFactoryImplementor
delegate()
findEntityGraphByName
(String name) Return the rootEntityGraph
with the given name, ornull
if there is no graph with the given name.<T> List<EntityGraph<? super T>>
findEntityGraphsByType
(Class<T> entityClass) Return allEntityGraph
s registered for the given entity type.getCache()
Obtain direct access to the underlying cache regions.getCollectionRolesByEntityParticipant
(String entityName) Deprecated.Obtains the current session, an instance ofSession
implicitly associated with some context or scope.Obtain the set of names of alldefined fetch profiles
.Obtain the set of names of alldefined filters
.Deprecated.Get the EventEngine associated with this SessionFactorygetFetchProfile
(String name) Retrieve fetch profile by name.getFilterDefinition
(String filterName) Deprecated.getGenerator
(String rootEntityName) Get the identifier generator for the hierarchygetIdentifierGenerator
(String rootEntityName) Get the identifier generator for the hierarchygetIdentifierPropertyName
(String className) getIdentifierType
(String className) Get the JdbcServices.Access to the domain model metadataWhen creatingFetch
references, defines a limit to how deep we should join for fetches.Deprecated.getName()
Access to the name (if one) assigned to the SessionFactorygetReferencedPropertyType
(String className, String propertyName) ASchemaManager
with the same default catalog and schema as pooled connections belonging to this factory.Access to the ServiceRegistry for this SessionFactory.Get the options used to build this factory.Retrieve the statistics for this factory.The java type to use for a tenant identifier.getUuid()
Get the UUID for this SessionFactory.boolean
isClosed()
Is this factory already closed?boolean
isOpen()
OverridesSessionFactory.openSession()
to widen the return type: this is useful for internal code depending onSessionFactoryImplementor
as it would otherwise need to frequently resort to casting to the internal contract.Open a new stateless session.openStatelessSession
(Connection connection) Open a new stateless session, utilizing the specified JDBCConnection
.Get a non-transactional "current" session (used by hibernate-envers)<T> BindableType<T>
resolveParameterBindType
(Class<T> clazz) Deprecated.<T> BindableType<? super T>
resolveParameterBindType
(T bindValue) Deprecated.<T> T
Obtain a session builder for creating newSession
s with certain customized options.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, fromStatelessSession, fromStatelessTransaction, fromTransaction, inSession, inStatelessSession, inStatelessTransaction, inTransaction
Methods inherited from interface org.hibernate.engine.spi.SessionFactoryImplementor
getMappingMetamodel, getSessionFactory
Methods inherited from interface org.hibernate.query.sqm.spi.SqmCreationContext
getNodeBuilder
-
Constructor Details
-
SessionFactoryDelegatingImpl
-
-
Method Details
-
delegate
-
getSessionFactoryOptions
Description copied from interface:SessionFactory
Get the options used to build this factory.- Specified by:
getSessionFactoryOptions
in interfaceSessionFactory
- Specified by:
getSessionFactoryOptions
in interfaceSessionFactoryImplementor
- Returns:
- The special options used to build the factory.
-
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
Description copied from interface:SessionFactoryImplementor
OverridesSessionFactory.openSession()
to widen the return type: this is useful for internal code depending onSessionFactoryImplementor
as it would otherwise need to frequently resort to casting to the internal contract.- Specified by:
openSession
in interfaceSessionFactory
- Specified by:
openSession
in interfaceSessionFactoryImplementor
- Returns:
- the opened Session.
- Throws:
HibernateException
- Indicates a problem opening the session; pretty rare here.
-
getCurrentSession
Description copied from interface:SessionFactory
Obtains the current session, an instance ofSession
implicitly associated with some context or scope. 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 support is enabled, thenJTASessionContext
is used, and the current session is scoped to the active JTA transaction.- Specified by:
getCurrentSession
in interfaceSessionFactory
- Returns:
- The current session.
- Throws:
HibernateException
- Indicates an issue locating a suitable current session.- See Also:
-
withStatelessOptions
Description copied from interface:SessionFactory
Obtain aStatelessSession
builder.- Specified by:
withStatelessOptions
in interfaceSessionFactory
- Returns:
- The stateless session builder
-
openStatelessSession
Description copied from interface:SessionFactory
Open a new stateless session.- Specified by:
openStatelessSession
in interfaceSessionFactory
- Returns:
- The created stateless session.
-
openStatelessSession
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
Description copied from interface:SessionFactory
Retrieve the statistics for this factory.- Specified by:
getStatistics
in interfaceSessionFactory
- Specified by:
getStatistics
in interfaceSessionFactoryImplementor
- Returns:
- The statistics.
-
getSchemaManager
Description copied from interface:SessionFactory
ASchemaManager
with the same default catalog and schema as pooled connections belonging to this factory. Intended mostly as a convenience for writing tests.- Specified by:
getSchemaManager
in interfaceSessionFactory
-
getRuntimeMetamodels
- Specified by:
getRuntimeMetamodels
in interfaceSessionFactoryImplementor
-
getEventEngine
Description copied from interface:SessionFactoryImplementor
Get the EventEngine associated with this SessionFactory- Specified by:
getEventEngine
in interfaceSessionFactoryImplementor
-
close
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 interfaceEntityManagerFactory
- 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
Description copied from interface:SessionFactory
Obtain direct access to the underlying cache regions.- Specified by:
getCache
in interfaceEntityManagerFactory
- Specified by:
getCache
in interfaceSessionFactory
- Specified by:
getCache
in interfaceSessionFactoryImplementor
- Returns:
- The direct cache access API.
-
getPersistenceUnitUtil
- Specified by:
getPersistenceUnitUtil
in interfaceEntityManagerFactory
-
addNamedQuery
- Specified by:
addNamedQuery
in interfaceEntityManagerFactory
-
unwrap
- Specified by:
unwrap
in interfaceEntityManagerFactory
-
addNamedEntityGraph
- Specified by:
addNamedEntityGraph
in interfaceEntityManagerFactory
-
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 given by
FilterDef
annotations
-
getFilterDefinition
@Deprecated public FilterDefinition getFilterDefinition(String filterName) throws HibernateException Deprecated.Description copied from interface:SessionFactory
Obtain the definition of a filter by name.- Specified by:
getFilterDefinition
in interfaceSessionFactory
- Specified by:
getFilterDefinition
in interfaceSessionFactoryImplementor
- 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.
-
getAutoEnabledFilters
- Specified by:
getAutoEnabledFilters
in interfaceSessionFactoryImplementor
-
containsFetchProfileDefinition
Description copied from interface:SessionFactory
Determine if there is 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.
-
getDefinedFetchProfileNames
Description copied from interface:SessionFactory
Obtain the set of names of alldefined fetch profiles
.- Specified by:
getDefinedFetchProfileNames
in interfaceSessionFactory
- Returns:
- The set of fetch profile names given by
FetchProfile
annotations.
-
getIdentifierGenerator
Description copied from interface:SessionFactoryImplementor
Get the identifier generator for the hierarchy- Specified by:
getIdentifierGenerator
in interfaceSessionFactoryImplementor
-
getGenerator
Description copied from interface:SessionFactoryImplementor
Get the identifier generator for the hierarchy- Specified by:
getGenerator
in interfaceSessionFactoryImplementor
-
getProperties
- Specified by:
getProperties
in interfaceEntityManagerFactory
-
getJdbcServices
Description copied from interface:SessionFactoryImplementor
Get the JdbcServices.- Specified by:
getJdbcServices
in interfaceSessionFactoryImplementor
- Returns:
- the JdbcServices
-
getSqlStringGenerationContext
- Specified by:
getSqlStringGenerationContext
in interfaceSessionFactoryImplementor
-
findEntityGraphByName
Description copied from interface:SessionFactory
Return the rootEntityGraph
with the given name, ornull
if there is no graph with the given name.- Specified by:
findEntityGraphByName
in interfaceSessionFactory
- Specified by:
findEntityGraphByName
in interfaceSessionFactoryImplementor
- Parameters:
name
- the name given to someNamedEntityGraph
- Returns:
- an instance of
RootGraph
- See Also:
-
bestGuessEntityName
Description copied from interface:SessionFactoryImplementor
The best guess entity name for an entity not in an association- Specified by:
bestGuessEntityName
in interfaceSessionFactoryImplementor
-
openTemporarySession
Description copied from interface:SessionFactoryImplementor
Get a non-transactional "current" session (used by hibernate-envers)- Specified by:
openTemporarySession
in interfaceSessionFactoryImplementor
- Throws:
HibernateException
-
getCollectionRolesByEntityParticipant
Deprecated. -
getEntityNotFoundDelegate
- Specified by:
getEntityNotFoundDelegate
in interfaceSessionFactoryImplementor
-
getFetchProfile
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
Description copied from interface:SqmCreationContext
Access to the domain model metadata- Specified by:
getJpaMetamodel
in interfaceSqmCreationContext
-
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
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
- Specified by:
addObserver
in interfaceSessionFactoryImplementor
-
getCustomEntityDirtinessStrategy
- Specified by:
getCustomEntityDirtinessStrategy
in interfaceSessionFactoryImplementor
-
getCurrentTenantIdentifierResolver
- Specified by:
getCurrentTenantIdentifierResolver
in interfaceSessionFactoryImplementor
-
getTenantIdentifierJavaType
Description copied from interface:SessionFactoryImplementor
The java type to use for a tenant identifier.- Specified by:
getTenantIdentifierJavaType
in interfaceSessionFactoryImplementor
-
getFastSessionServices
- Specified by:
getFastSessionServices
in interfaceSessionFactoryImplementor
- Returns:
- the FastSessionServices instance associated with this SessionFactory
-
getDeserializationResolver
@Deprecated public SessionFactoryImplementor.DeserializationResolver<?> getDeserializationResolver()Deprecated.- Specified by:
getDeserializationResolver
in interfaceSessionFactoryImplementor
-
getIdentifierType
- Specified by:
getIdentifierType
in interfaceMapping
- Throws:
MappingException
-
getIdentifierPropertyName
- 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
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:
-
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
- Specified by:
getTypeConfiguration
in interfaceQueryParameterBindingTypeResolver
- Specified by:
getTypeConfiguration
in interfaceSessionFactoryImplementor
- Specified by:
getTypeConfiguration
in interfaceSqmCreationContext
-
getQueryEngine
- Specified by:
getQueryEngine
in interfaceSessionFactoryImplementor
- Specified by:
getQueryEngine
in interfaceSqmCreationContext
-
getReference
- Specified by:
getReference
in interfaceReferenceable
- Throws:
NamingException
-
createEntityManager
- Specified by:
createEntityManager
in interfaceEntityManagerFactory
-
createEntityManager
- Specified by:
createEntityManager
in interfaceEntityManagerFactory
-
createEntityManager
- Specified by:
createEntityManager
in interfaceEntityManagerFactory
-
createEntityManager
- Specified by:
createEntityManager
in interfaceEntityManagerFactory
-
getCriteriaBuilder
Description copied from interface:SessionFactory
- Specified by:
getCriteriaBuilder
in interfaceEntityManagerFactory
- Specified by:
getCriteriaBuilder
in interfaceSessionFactory
- Specified by:
getCriteriaBuilder
in interfaceSessionFactoryImplementor
- See Also:
-
getMetamodel
Deprecated.- Specified by:
getMetamodel
in interfaceEntityManagerFactory
- Specified by:
getMetamodel
in interfaceSessionFactoryImplementor
-
isOpen
public boolean isOpen()- Specified by:
isOpen
in interfaceEntityManagerFactory
-
resolveParameterBindType
Deprecated.- Specified by:
resolveParameterBindType
in interfaceQueryParameterBindingTypeResolver
- Specified by:
resolveParameterBindType
in interfaceSessionFactoryImplementor
-
resolveParameterBindType
Deprecated.- Specified by:
resolveParameterBindType
in interfaceQueryParameterBindingTypeResolver
- Specified by:
resolveParameterBindType
in interfaceSessionFactoryImplementor
-
getWrapperOptions
- Specified by:
getWrapperOptions
in interfaceSessionFactoryImplementor
-
findEntityGraphsByType
Description copied from interface:SessionFactory
Return allEntityGraph
s registered for the given entity type.- Specified by:
findEntityGraphsByType
in interfaceSessionFactory
- See Also:
-