Class SessionFactoryDelegatingImpl
- All Implemented Interfaces:
EntityManagerFactory,Closeable,Serializable,AutoCloseable,Referenceable,Mapping,SessionFactoryImplementor,QueryParameterBindingTypeResolver,SqmCreationContext,SessionFactory,SqlAstCreationContext
SessionFactory and
SessionFactoryImplementor contracts for intended for easier
implementation of SessionFactory.- Author:
- Steve Ebersole
- 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> voidaddNamedEntityGraph(String graphName, EntityGraph<T> entityGraph) Add a named copy of the EntityGraph to the EntityManagerFactory.voidaddNamedQuery(String name, Query query) Define the query, typed query, or stored procedure query as a named query such that future query objects can be created from it using thecreateNamedQueryorcreateNamedStoredProcedureQuerymethod.voidaddObserver(SessionFactoryObserver observer) bestGuessEntityName(Object object) The best guess entity name for an entity not in an associationvoidclose()Destroy thisSessionFactoryand release all its resources, including caches and connection pools.booleanDetermine if there is a fetch profile definition registered under the given name.Create a new application-managedEntityManager.createEntityManager(SynchronizationType synchronizationType) Create a new JTA application-managedEntityManagerwith the specified synchronization type.createEntityManager(SynchronizationType synchronizationType, Map map) Create a new JTA application-managedEntityManagerwith the specified synchronization type and map of properties.createEntityManager(Map map) Create a new application-managedEntityManagerwith the specified Map of properties.protected SessionFactoryImplementordelegate()findEntityGraphByName(String name) Return the rootEntityGraphwith the given name, ornullif there is no graph with the given name.<T> List<EntityGraph<? super T>>findEntityGraphsByType(Class<T> entityClass) Return allEntityGraphs 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 ofSessionimplicitly 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 creatingFetchreferences, defines a limit to how deep we should join for fetches.Deprecated.getName()Access to the name (if one) assigned to the SessionFactoryReturn interface providing access to utility methods for the persistence unit.Get the properties and associated values that are in effect for the entity manager factory.getReferencedPropertyType(String className, String propertyName) ASchemaManagerwith 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.booleanisClosed()Is this factory already closed?booleanisOpen()Indicates whether the factory is open.OverridesSessionFactory.openSession()to widen the return type: this is useful for internal code depending onSessionFactoryImplementoras 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> TReturn an object of the specified type to allow access to the provider-specific API.Obtain a session builder for creating newSessions with certain customized options.Obtain aStatelessSessionbuilder.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.hibernate.SessionFactory
fromSession, fromStatelessSession, fromStatelessTransaction, fromTransaction, inSession, inStatelessSession, inStatelessTransaction, inTransactionMethods inherited from interface org.hibernate.engine.spi.SessionFactoryImplementor
getMappingMetamodel, getSessionFactoryMethods inherited from interface org.hibernate.query.sqm.spi.SqmCreationContext
getNodeBuilder
-
Constructor Details
-
SessionFactoryDelegatingImpl
-
-
Method Details
-
delegate
-
getSessionFactoryOptions
Description copied from interface:SessionFactoryGet the options used to build this factory.- Specified by:
getSessionFactoryOptionsin interfaceSessionFactory- Specified by:
getSessionFactoryOptionsin interfaceSessionFactoryImplementor- Returns:
- The special options used to build the factory.
-
withOptions
Description copied from interface:SessionFactoryObtain a session builder for creating newSessions with certain customized options.- Specified by:
withOptionsin interfaceSessionFactory- Specified by:
withOptionsin interfaceSessionFactoryImplementor- Returns:
- The session builder
-
openSession
Description copied from interface:SessionFactoryImplementorOverridesSessionFactory.openSession()to widen the return type: this is useful for internal code depending onSessionFactoryImplementoras it would otherwise need to frequently resort to casting to the internal contract.- Specified by:
openSessionin interfaceSessionFactory- Specified by:
openSessionin interfaceSessionFactoryImplementor- Returns:
- the opened Session.
- Throws:
HibernateException- Indicates a problem opening the session; pretty rare here.
-
getCurrentSession
Description copied from interface:SessionFactoryObtains the current session, an instance ofSessionimplicitly 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
CurrentSessionContextis explicitly configured, but JTA support is enabled, thenJTASessionContextis used, and the current session is scoped to the active JTA transaction.- Specified by:
getCurrentSessionin interfaceSessionFactory- Returns:
- The current session.
- Throws:
HibernateException- Indicates an issue locating a suitable current session.- See Also:
-
withStatelessOptions
Description copied from interface:SessionFactoryObtain aStatelessSessionbuilder.- Specified by:
withStatelessOptionsin interfaceSessionFactory- Returns:
- The stateless session builder
-
openStatelessSession
Description copied from interface:SessionFactoryOpen a new stateless session.- Specified by:
openStatelessSessionin interfaceSessionFactory- Returns:
- The created stateless session.
-
openStatelessSession
Description copied from interface:SessionFactoryOpen a new stateless session, utilizing the specified JDBCConnection.- Specified by:
openStatelessSessionin interfaceSessionFactory- Parameters:
connection- Connection provided by the application.- Returns:
- The created stateless session.
-
getStatistics
Description copied from interface:SessionFactoryRetrieve the statistics for this factory.- Specified by:
getStatisticsin interfaceSessionFactory- Specified by:
getStatisticsin interfaceSessionFactoryImplementor- Returns:
- The statistics.
-
getSchemaManager
Description copied from interface:SessionFactoryASchemaManagerwith the same default catalog and schema as pooled connections belonging to this factory. Intended mostly as a convenience for writing tests.- Specified by:
getSchemaManagerin interfaceSessionFactory
-
getRuntimeMetamodels
- Specified by:
getRuntimeMetamodelsin interfaceSessionFactoryImplementor
-
getEventEngine
Description copied from interface:SessionFactoryImplementorGet the EventEngine associated with this SessionFactory- Specified by:
getEventEnginein interfaceSessionFactoryImplementor
-
close
Description copied from interface:SessionFactoryDestroy thisSessionFactoryand 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceEntityManagerFactory- Specified by:
closein interfaceSessionFactory- Throws:
HibernateException- Indicates an issue closing the factory.
-
isClosed
public boolean isClosed()Description copied from interface:SessionFactoryIs this factory already closed?- Specified by:
isClosedin interfaceSessionFactory- Returns:
- True if this factory is already closed; false otherwise.
-
getCache
Description copied from interface:SessionFactoryObtain direct access to the underlying cache regions.- Specified by:
getCachein interfaceEntityManagerFactory- Specified by:
getCachein interfaceSessionFactory- Specified by:
getCachein interfaceSessionFactoryImplementor- Returns:
- The direct cache access API.
-
getPersistenceUnitUtil
Description copied from interface:EntityManagerFactoryReturn interface providing access to utility methods for the persistence unit.- Specified by:
getPersistenceUnitUtilin interfaceEntityManagerFactory- Returns:
PersistenceUnitUtilinterface
-
addNamedQuery
Description copied from interface:EntityManagerFactoryDefine the query, typed query, or stored procedure query as a named query such that future query objects can be created from it using thecreateNamedQueryorcreateNamedStoredProcedureQuerymethod.Any configuration of the query object (except for actual parameter binding) in effect when the named query is added is retained as part of the named query definition. This includes configuration information such as max results, hints, flush mode, lock mode, result set mapping information, and information about stored procedure parameters.
When the query is executed, information that can be set by means of the query APIs can be overridden. Information that is overridden does not affect the named query as registered with the entity manager factory, and thus does not affect subsequent query objects created from it by means of the
createNamedQueryorcreateNamedStoredProcedureQuerymethod.If a named query of the same name has been previously defined, either statically via metadata or via this method, that query definition is replaced.
- Specified by:
addNamedQueryin interfaceEntityManagerFactory- Parameters:
name- name for the queryquery- Query, TypedQuery, or StoredProcedureQuery object
-
unwrap
Description copied from interface:EntityManagerFactoryReturn an object of the specified type to allow access to the provider-specific API. If the provider's EntityManagerFactory implementation does not support the specified class, the PersistenceException is thrown.- Specified by:
unwrapin interfaceEntityManagerFactory- Parameters:
cls- the class of the object to be returned. This is normally either the underlying EntityManagerFactory implementation class or an interface that it implements.- Returns:
- an instance of the specified class
-
addNamedEntityGraph
Description copied from interface:EntityManagerFactoryAdd a named copy of the EntityGraph to the EntityManagerFactory. If an entity graph with the same name already exists, it is replaced.- Specified by:
addNamedEntityGraphin interfaceEntityManagerFactory- Parameters:
graphName- name for the entity graphentityGraph- entity graph
-
getDefinedFilterNames
Description copied from interface:SessionFactoryObtain the set of names of alldefined filters.- Specified by:
getDefinedFilterNamesin interfaceSessionFactory- Returns:
- The set of filter names given by
FilterDefannotations
-
getFilterDefinition
@Deprecated public FilterDefinition getFilterDefinition(String filterName) throws HibernateException Deprecated.Description copied from interface:SessionFactoryObtain the definition of a filter by name.- Specified by:
getFilterDefinitionin interfaceSessionFactory- Specified by:
getFilterDefinitionin 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:
getAutoEnabledFiltersin interfaceSessionFactoryImplementor
-
containsFetchProfileDefinition
Description copied from interface:SessionFactoryDetermine if there is a fetch profile definition registered under the given name.- Specified by:
containsFetchProfileDefinitionin interfaceSessionFactory- Parameters:
name- The name to check- Returns:
- True if there is such a fetch profile; false otherwise.
-
getDefinedFetchProfileNames
Description copied from interface:SessionFactoryObtain the set of names of alldefined fetch profiles.- Specified by:
getDefinedFetchProfileNamesin interfaceSessionFactory- Returns:
- The set of fetch profile names given by
FetchProfileannotations.
-
getIdentifierGenerator
Description copied from interface:SessionFactoryImplementorGet the identifier generator for the hierarchy- Specified by:
getIdentifierGeneratorin interfaceSessionFactoryImplementor
-
getGenerator
Description copied from interface:SessionFactoryImplementorGet the identifier generator for the hierarchy- Specified by:
getGeneratorin interfaceSessionFactoryImplementor
-
getProperties
Description copied from interface:EntityManagerFactoryGet the properties and associated values that are in effect for the entity manager factory. Changing the contents of the map does not change the configuration in effect.- Specified by:
getPropertiesin interfaceEntityManagerFactory- Returns:
- properties
-
getJdbcServices
Description copied from interface:SessionFactoryImplementorGet the JdbcServices.- Specified by:
getJdbcServicesin interfaceSessionFactoryImplementor- Returns:
- the JdbcServices
-
getSqlStringGenerationContext
- Specified by:
getSqlStringGenerationContextin interfaceSessionFactoryImplementor
-
findEntityGraphByName
Description copied from interface:SessionFactoryReturn the rootEntityGraphwith the given name, ornullif there is no graph with the given name.- Specified by:
findEntityGraphByNamein interfaceSessionFactory- Specified by:
findEntityGraphByNamein interfaceSessionFactoryImplementor- Parameters:
name- the name given to someNamedEntityGraph- Returns:
- an instance of
RootGraph - See Also:
-
bestGuessEntityName
Description copied from interface:SessionFactoryImplementorThe best guess entity name for an entity not in an association- Specified by:
bestGuessEntityNamein interfaceSessionFactoryImplementor
-
openTemporarySession
Description copied from interface:SessionFactoryImplementorGet a non-transactional "current" session (used by hibernate-envers)- Specified by:
openTemporarySessionin interfaceSessionFactoryImplementor- Throws:
HibernateException
-
getCollectionRolesByEntityParticipant
Deprecated. -
getEntityNotFoundDelegate
- Specified by:
getEntityNotFoundDelegatein interfaceSessionFactoryImplementor
-
getFetchProfile
Description copied from interface:SessionFactoryImplementorRetrieve fetch profile by name.- Specified by:
getFetchProfilein interfaceSessionFactoryImplementor- Parameters:
name- The name of the profile to retrieve.- Returns:
- The profile definition
-
getJpaMetamodel
Description copied from interface:SqmCreationContextAccess to the domain model metadata- Specified by:
getJpaMetamodelin interfaceSqmCreationContext
-
getServiceRegistry
Description copied from interface:SessionFactoryImplementorAccess to the ServiceRegistry for this SessionFactory.- Specified by:
getServiceRegistryin interfaceSessionFactoryImplementor- Specified by:
getServiceRegistryin interfaceSqlAstCreationContext- Specified by:
getServiceRegistryin interfaceSqmCreationContext- Returns:
- The factory's ServiceRegistry
-
getMaximumFetchDepth
Description copied from interface:SqlAstCreationContextWhen creatingFetchreferences, defines a limit to how deep we should join for fetches.- Specified by:
getMaximumFetchDepthin interfaceSqlAstCreationContext
-
addObserver
- Specified by:
addObserverin interfaceSessionFactoryImplementor
-
getCustomEntityDirtinessStrategy
- Specified by:
getCustomEntityDirtinessStrategyin interfaceSessionFactoryImplementor
-
getCurrentTenantIdentifierResolver
- Specified by:
getCurrentTenantIdentifierResolverin interfaceSessionFactoryImplementor
-
getTenantIdentifierJavaType
Description copied from interface:SessionFactoryImplementorThe java type to use for a tenant identifier.- Specified by:
getTenantIdentifierJavaTypein interfaceSessionFactoryImplementor
-
getFastSessionServices
- Specified by:
getFastSessionServicesin interfaceSessionFactoryImplementor- Returns:
- the FastSessionServices instance associated with this SessionFactory
-
getDeserializationResolver
@Deprecated public SessionFactoryImplementor.DeserializationResolver<?> getDeserializationResolver()Deprecated.- Specified by:
getDeserializationResolverin interfaceSessionFactoryImplementor
-
getIdentifierType
- Specified by:
getIdentifierTypein interfaceMapping- Throws:
MappingException
-
getIdentifierPropertyName
- Specified by:
getIdentifierPropertyNamein interfaceMapping- Throws:
MappingException
-
getReferencedPropertyType
public Type getReferencedPropertyType(String className, String propertyName) throws MappingException - Specified by:
getReferencedPropertyTypein interfaceMapping- Throws:
MappingException
-
getUuid
Description copied from interface:SessionFactoryImplementorGet the UUID for this SessionFactory.The value is generated as a
UUID, but kept as a String.- Specified by:
getUuidin interfaceSessionFactoryImplementor- Returns:
- The UUID for this SessionFactory.
- See Also:
-
getName
Description copied from interface:SessionFactoryImplementorAccess to the name (if one) assigned to the SessionFactory- Specified by:
getNamein interfaceSessionFactoryImplementor- Returns:
- The name for the SessionFactory
-
getTypeConfiguration
- Specified by:
getTypeConfigurationin interfaceQueryParameterBindingTypeResolver- Specified by:
getTypeConfigurationin interfaceSessionFactoryImplementor- Specified by:
getTypeConfigurationin interfaceSqmCreationContext
-
getQueryEngine
- Specified by:
getQueryEnginein interfaceSessionFactoryImplementor- Specified by:
getQueryEnginein interfaceSqmCreationContext
-
getReference
- Specified by:
getReferencein interfaceReferenceable- Throws:
NamingException
-
createEntityManager
Description copied from interface:EntityManagerFactoryCreate a new application-managedEntityManager. This method returns a newEntityManagerinstance each time it is invoked. TheisOpenmethod will return true on the returned instance.- Specified by:
createEntityManagerin interfaceEntityManagerFactory- Returns:
- entity manager instance
-
createEntityManager
Description copied from interface:EntityManagerFactoryCreate a new application-managedEntityManagerwith the specified Map of properties. This method returns a newEntityManagerinstance each time it is invoked. TheisOpenmethod will return true on the returned instance.- Specified by:
createEntityManagerin interfaceEntityManagerFactory- Parameters:
map- properties for entity manager- Returns:
- entity manager instance
-
createEntityManager
Description copied from interface:EntityManagerFactoryCreate a new JTA application-managedEntityManagerwith the specified synchronization type. This method returns a newEntityManagerinstance each time it is invoked. TheisOpenmethod will return true on the returned instance.- Specified by:
createEntityManagerin interfaceEntityManagerFactory- Parameters:
synchronizationType- how and when the entity manager should be synchronized with the current JTA transaction- Returns:
- entity manager instance
-
createEntityManager
Description copied from interface:EntityManagerFactoryCreate a new JTA application-managedEntityManagerwith the specified synchronization type and map of properties. This method returns a newEntityManagerinstance each time it is invoked. TheisOpenmethod will return true on the returned instance.- Specified by:
createEntityManagerin interfaceEntityManagerFactory- Parameters:
synchronizationType- how and when the entity manager should be synchronized with the current JTA transactionmap- properties for entity manager- Returns:
- entity manager instance
-
getCriteriaBuilder
Description copied from interface:SessionFactory- Specified by:
getCriteriaBuilderin interfaceEntityManagerFactory- Specified by:
getCriteriaBuilderin interfaceSessionFactory- Specified by:
getCriteriaBuilderin interfaceSessionFactoryImplementor- Returns:
- CriteriaBuilder instance
- See Also:
-
getMetamodel
Deprecated.Description copied from interface:EntityManagerFactoryReturn an instance ofMetamodelinterface for access to the metamodel of the persistence unit.- Specified by:
getMetamodelin interfaceEntityManagerFactory- Specified by:
getMetamodelin interfaceSessionFactoryImplementor- Returns:
- Metamodel instance
-
isOpen
public boolean isOpen()Description copied from interface:EntityManagerFactoryIndicates whether the factory is open. Returns true until the factory has been closed.- Specified by:
isOpenin interfaceEntityManagerFactory- Returns:
- boolean indicating whether the factory is open
-
resolveParameterBindType
Deprecated.- Specified by:
resolveParameterBindTypein interfaceQueryParameterBindingTypeResolver- Specified by:
resolveParameterBindTypein interfaceSessionFactoryImplementor
-
resolveParameterBindType
Deprecated.- Specified by:
resolveParameterBindTypein interfaceQueryParameterBindingTypeResolver- Specified by:
resolveParameterBindTypein interfaceSessionFactoryImplementor
-
getWrapperOptions
- Specified by:
getWrapperOptionsin interfaceSessionFactoryImplementor
-
findEntityGraphsByType
Description copied from interface:SessionFactoryReturn allEntityGraphs registered for the given entity type.- Specified by:
findEntityGraphsByTypein interfaceSessionFactory- See Also:
-