类 SessionFactoryImpl
- java.lang.Object
-
- org.hibernate.internal.SessionFactoryImpl
-
- 所有已实现的接口:
Closeable,Serializable,AutoCloseable,Referenceable,javax.persistence.EntityManagerFactory,Mapping,SessionFactoryImplementor,HibernateEntityManagerFactory,QueryParameterBindingTypeResolver,SessionFactory
public class SessionFactoryImpl extends Object implements SessionFactoryImplementor
Concrete implementation of the SessionFactory interface. Has the following responsibilities- caches configuration settings (immutably)
- caches "compiled" mappings ie. EntityPersisters and CollectionPersisters (immutable)
- caches "compiled" queries (memory sensitive cache)
- manages PreparedStatements
- delegates JDBC Connection management to the ConnectionProvider
- factory for instances of SessionImpl
- 作者:
- Gavin King, Steve Ebersole, Chris Cranford
- 另请参阅:
- 序列化表格
-
-
嵌套类概要
嵌套类 修饰符和类型 类 说明 static classSessionFactoryImpl.SessionBuilderImpl<T extends SessionBuilder>static classSessionFactoryImpl.StatelessSessionBuilderImpl-
从接口继承的嵌套类/接口 org.hibernate.engine.spi.SessionFactoryImplementor
SessionFactoryImplementor.DeserializationResolver<T extends SessionFactoryImplementor>
-
-
构造器概要
构造器 构造器 说明 SessionFactoryImpl(MetadataImplementor metadata, SessionFactoryOptions options)
-
方法概要
所有方法 静态方法 实例方法 具体方法 已过时的方法 修饰符和类型 方法 说明 <T> voidaddNamedEntityGraph(String graphName, javax.persistence.EntityGraph<T> entityGraph)voidaddNamedQuery(String name, javax.persistence.Query query)voidaddObserver(SessionFactoryObserver observer)voidclose()Closes the session factory, releasing all held resources.static InterceptorconfiguredInterceptor(Interceptor interceptor, SessionFactoryOptions options)booleancontainsFetchProfileDefinition(String name)Determine if this session factory contains a fetch profile definition registered under the given name.SessioncreateEntityManager()SessioncreateEntityManager(Map map)SessioncreateEntityManager(javax.persistence.SynchronizationType synchronizationType)SessioncreateEntityManager(javax.persistence.SynchronizationType synchronizationType, Map map)RootGraphImplementorfindEntityGraphByName(String name)<T> List<RootGraphImplementor<? super T>>findEntityGraphsByJavaType(Class<T> entityClass)Map<String,ClassMetadata>getAllClassMetadata()Retrieve theClassMetadatafor all mapped entities.MapgetAllCollectionMetadata()Get theCollectionMetadatafor all mapped collections.CacheImplementorgetCache()Obtain direct access to the underlying cache regions.ClassMetadatagetClassMetadata(Class persistentClass)Retrieve theClassMetadataassociated with the given entity class.ClassMetadatagetClassMetadata(String entityName)Retrieve theClassMetadataassociated with the given entity class.CollectionMetadatagetCollectionMetadata(String roleName)Get theCollectionMetadataassociated with the named collection role.javax.persistence.criteria.CriteriaBuildergetCriteriaBuilder()SessiongetCurrentSession()Obtains the current session.CurrentTenantIdentifierResolvergetCurrentTenantIdentifierResolver()CustomEntityDirtinessStrategygetCustomEntityDirtinessStrategy()SetgetDefinedFilterNames()Obtain a set of the names of all filters defined on this SessionFactory.SessionFactoryImplementor.DeserializationResolvergetDeserializationResolver()EntityNotFoundDelegategetEntityNotFoundDelegate()FetchProfilegetFetchProfile(String name)Retrieve fetch profile by name.FilterDefinitiongetFilterDefinition(String filterName)Obtain the definition of a filter by name.IdentifierGeneratorgetIdentifierGenerator(String rootEntityName)Get the identifier generator for the hierarchyIdentifierGeneratorFactorygetIdentifierGeneratorFactory()Allow access to the id generator factory, though this is only needed/allowed from configuration.StringgetIdentifierPropertyName(String className)TypegetIdentifierType(String className)InterceptorgetInterceptor()Get the factory scoped interceptor for this factory.JdbcServicesgetJdbcServices()Get the JdbcServices.MetamodelImplementorgetMetamodel()StringgetName()Access to the name (if one) assigned to the SessionFactoryNamedQueryRepositorygetNamedQueryRepository()Provides access to the named query repositoryjavax.persistence.PersistenceUnitUtilgetPersistenceUnitUtil()Map<String,Object>getProperties()QueryPlanCachegetQueryPlanCache()Access to the caches of HQL/JPQL and native query plans.ReferencegetReference()TypegetReferencedPropertyType(String className, String propertyName)String[]getReturnAliases(String queryString)Get the return aliases of a queryType[]getReturnTypes(String queryString)Get the return types of a queryServiceRegistryImplementorgetServiceRegistry()Access to the ServiceRegistry for this SessionFactory.SessionFactoryOptionsgetSessionFactoryOptions()Get the special options used to build the factory.SettingsgetSettings()SQLFunctionRegistrygetSqlFunctionRegistry()StatisticsImplementorgetStatistics()Retrieve the statistics for this factory.TypeHelpergetTypeHelper()Retrieve this factory'sTypeHelper.TypeResolvergetTypeResolver()已过时。(since 5.3) No replacement, access to and handling of Types will be much different in 6.0StringgetUuid()Get the UUID for this SessionFactory.booleanisClosed()Is this factory already closed?booleanisOpen()SessionopenSession()Open aSession.StatelessSessionopenStatelessSession()Open a new stateless session.StatelessSessionopenStatelessSession(Connection connection)Open a new stateless session, utilizing the specified JDBCConnection.SessionopenTemporarySession()Get a non-transactional "current" session (used by hibernate-envers)TyperesolveParameterBindType(Class clazz)TyperesolveParameterBindType(Object bindValue)<T> Tunwrap(Class<T> type)protected voidvalidateNotClosed()SessionBuilderImplementorwithOptions()Obtain aSessionbuilder.StatelessSessionBuilderwithStatelessOptions()Obtain aStatelessSessionbuilder.-
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
从接口继承的方法 org.hibernate.jpa.HibernateEntityManagerFactory
getEntityManagerFactoryName, getEntityTypeByName, getSessionFactory
-
从接口继承的方法 org.hibernate.engine.spi.SessionFactoryImplementor
findEntityGraphsByType, getCollectionPersister, getCollectionPersisters, getCollectionRolesByEntityParticipant, getDialect, getEntityPersister, getEntityPersisters, getImplementors, getImportedClassName, getNamedQuery, getNamedSQLQuery, getResultSetMapping, getSQLExceptionConverter, getSQLExceptionHelper, getStatisticsImplementor, iterateEntityNameResolvers, locateEntityPersister, locateEntityPersister, registerNamedQueryDefinition, registerNamedSQLQueryDefinition
-
-
-
-
构造器详细资料
-
SessionFactoryImpl
public SessionFactoryImpl(MetadataImplementor metadata, SessionFactoryOptions options)
-
-
方法详细资料
-
openSession
public Session openSession() throws HibernateException
从接口复制的说明:SessionFactoryOpen aSession. JDBCconnection(swill be obtained from the configuredConnectionProvideras needed to perform requested work.- 指定者:
openSession在接口中SessionFactory- 返回:
- The created session.
- 抛出:
HibernateException- Indicates a problem opening the session; pretty rare here.
-
openTemporarySession
public Session openTemporarySession() throws HibernateException
从接口复制的说明:SessionFactoryImplementorGet a non-transactional "current" session (used by hibernate-envers)- 指定者:
openTemporarySession在接口中SessionFactoryImplementor- 抛出:
HibernateException
-
getCurrentSession
public Session getCurrentSession() throws HibernateException
从接口复制的说明:SessionFactoryObtains the current session. The definition of what exactly "current" means controlled by theCurrentSessionContextimpl configured for use. Note that for backwards compatibility, if aCurrentSessionContextis not configured but JTA is configured this will default to theJTASessionContextimpl.- 指定者:
getCurrentSession在接口中SessionFactory- 返回:
- The current session.
- 抛出:
HibernateException- Indicates an issue locating a suitable current session.
-
withOptions
public SessionBuilderImplementor withOptions()
从接口复制的说明:SessionFactoryObtain aSessionbuilder.- 指定者:
withOptions在接口中SessionFactory- 指定者:
withOptions在接口中SessionFactoryImplementor- 返回:
- The session builder
-
withStatelessOptions
public StatelessSessionBuilder withStatelessOptions()
从接口复制的说明:SessionFactoryObtain aStatelessSessionbuilder.- 指定者:
withStatelessOptions在接口中SessionFactory- 返回:
- The stateless session builder
-
openStatelessSession
public StatelessSession openStatelessSession()
从接口复制的说明:SessionFactoryOpen a new stateless session.- 指定者:
openStatelessSession在接口中SessionFactory- 返回:
- The created stateless session.
-
openStatelessSession
public StatelessSession openStatelessSession(Connection connection)
从接口复制的说明:SessionFactoryOpen a new stateless session, utilizing the specified JDBCConnection.- 指定者:
openStatelessSession在接口中SessionFactory- 参数:
connection- Connection provided by the application.- 返回:
- The created stateless session.
-
addObserver
public void addObserver(SessionFactoryObserver observer)
- 指定者:
addObserver在接口中SessionFactoryImplementor
-
getProperties
public Map<String,Object> getProperties()
- 指定者:
getProperties在接口中javax.persistence.EntityManagerFactory
-
validateNotClosed
protected void validateNotClosed()
-
getUuid
public String getUuid()
从接口复制的说明:SessionFactoryImplementorGet the UUID for this SessionFactory. The value is generated as aUUID, but kept as a String.- 指定者:
getUuid在接口中SessionFactoryImplementor- 返回:
- The UUID for this SessionFactory.
- 另请参阅:
SessionFactoryRegistry.getSessionFactory(java.lang.String)
-
getName
public String getName()
从接口复制的说明:SessionFactoryImplementorAccess to the name (if one) assigned to the SessionFactory- 指定者:
getName在接口中SessionFactoryImplementor- 返回:
- The name for the SessionFactory
-
getJdbcServices
public JdbcServices getJdbcServices()
从接口复制的说明:SessionFactoryImplementorGet the JdbcServices.- 指定者:
getJdbcServices在接口中SessionFactoryImplementor- 返回:
- the JdbcServices
-
getIdentifierGeneratorFactory
public IdentifierGeneratorFactory getIdentifierGeneratorFactory()
从接口复制的说明:MappingAllow access to the id generator factory, though this is only needed/allowed from configuration.- 指定者:
getIdentifierGeneratorFactory在接口中Mapping- 返回:
- Access to the identifier generator factory
-
getTypeResolver
@Deprecated public TypeResolver getTypeResolver()
已过时。(since 5.3) No replacement, access to and handling of Types will be much different in 6.0Retrieve theTyperesolver associated with this factory.- 指定者:
getTypeResolver在接口中SessionFactoryImplementor- 返回:
- The type resolver
-
getQueryPlanCache
public QueryPlanCache getQueryPlanCache()
从接口复制的说明:SessionFactoryImplementorAccess to the caches of HQL/JPQL and native query plans.- 指定者:
getQueryPlanCache在接口中SessionFactoryImplementor- 返回:
- The query plan cache
-
getDeserializationResolver
public SessionFactoryImplementor.DeserializationResolver getDeserializationResolver()
-
getSettings
public Settings getSettings()
- 指定者:
getSettings在接口中SessionFactoryImplementor
-
findEntityGraphsByJavaType
public <T> List<RootGraphImplementor<? super T>> findEntityGraphsByJavaType(Class<T> entityClass)
-
createEntityManager
public Session createEntityManager()
- 指定者:
createEntityManager在接口中javax.persistence.EntityManagerFactory
-
createEntityManager
public Session createEntityManager(Map map)
- 指定者:
createEntityManager在接口中javax.persistence.EntityManagerFactory
-
createEntityManager
public Session createEntityManager(javax.persistence.SynchronizationType synchronizationType)
- 指定者:
createEntityManager在接口中javax.persistence.EntityManagerFactory
-
createEntityManager
public Session createEntityManager(javax.persistence.SynchronizationType synchronizationType, Map map)
- 指定者:
createEntityManager在接口中javax.persistence.EntityManagerFactory
-
getCriteriaBuilder
public javax.persistence.criteria.CriteriaBuilder getCriteriaBuilder()
- 指定者:
getCriteriaBuilder在接口中javax.persistence.EntityManagerFactory
-
getMetamodel
public MetamodelImplementor getMetamodel()
- 指定者:
getMetamodel在接口中javax.persistence.EntityManagerFactory- 指定者:
getMetamodel在接口中HibernateEntityManagerFactory- 指定者:
getMetamodel在接口中SessionFactoryImplementor
-
isOpen
public boolean isOpen()
- 指定者:
isOpen在接口中javax.persistence.EntityManagerFactory
-
findEntityGraphByName
public RootGraphImplementor findEntityGraphByName(String name)
-
getSessionFactoryOptions
public SessionFactoryOptions getSessionFactoryOptions()
从接口复制的说明:SessionFactoryGet the special options used to build the factory.- 指定者:
getSessionFactoryOptions在接口中SessionFactory- 返回:
- The special options used to build the factory.
-
getInterceptor
public Interceptor getInterceptor()
从接口复制的说明:SessionFactoryImplementorGet the factory scoped interceptor for this factory.- 指定者:
getInterceptor在接口中SessionFactoryImplementor- 返回:
- The factory scope interceptor, or null if none.
-
getReference
public Reference getReference()
- 指定者:
getReference在接口中Referenceable
-
getNamedQueryRepository
public NamedQueryRepository getNamedQueryRepository()
从接口复制的说明:SessionFactoryImplementorProvides access to the named query repository- 指定者:
getNamedQueryRepository在接口中SessionFactoryImplementor- 返回:
- The repository for named query definitions
-
getIdentifierType
public Type getIdentifierType(String className) throws MappingException
- 指定者:
getIdentifierType在接口中Mapping- 抛出:
MappingException
-
getIdentifierPropertyName
public String getIdentifierPropertyName(String className) throws MappingException
- 指定者:
getIdentifierPropertyName在接口中Mapping- 抛出:
MappingException
-
getReturnTypes
public Type[] getReturnTypes(String queryString) throws HibernateException
从接口复制的说明:SessionFactoryImplementorGet the return types of a query- 指定者:
getReturnTypes在接口中SessionFactoryImplementor- 抛出:
HibernateException
-
getReturnAliases
public String[] getReturnAliases(String queryString) throws HibernateException
从接口复制的说明:SessionFactoryImplementorGet the return aliases of a query- 指定者:
getReturnAliases在接口中SessionFactoryImplementor- 抛出:
HibernateException
-
getClassMetadata
public ClassMetadata getClassMetadata(Class persistentClass) throws HibernateException
从接口复制的说明:SessionFactoryRetrieve theClassMetadataassociated with the given entity class.- 指定者:
getClassMetadata在接口中SessionFactory- 参数:
persistentClass- The entity class- 返回:
- The metadata associated with the given entity; may be null if no such entity was mapped.
- 抛出:
HibernateException- Generally null is returned instead of throwing.
-
getCollectionMetadata
public CollectionMetadata getCollectionMetadata(String roleName) throws HibernateException
从接口复制的说明:SessionFactoryGet theCollectionMetadataassociated with the named collection role.- 指定者:
getCollectionMetadata在接口中SessionFactory- 参数:
roleName- The collection role (in form [owning-entity-name].[collection-property-name]).- 返回:
- The metadata associated with the given collection; may be null if no such collection was mapped.
- 抛出:
HibernateException- Generally null is returned instead of throwing.
-
getClassMetadata
public ClassMetadata getClassMetadata(String entityName) throws HibernateException
从接口复制的说明:SessionFactoryRetrieve theClassMetadataassociated with the given entity class.- 指定者:
getClassMetadata在接口中SessionFactory- 参数:
entityName- The entity class- 返回:
- The metadata associated with the given entity; may be null if no such entity was mapped.
- 抛出:
HibernateException- Generally null is returned instead of throwing.
-
getAllClassMetadata
public Map<String,ClassMetadata> getAllClassMetadata() throws HibernateException
从接口复制的说明:SessionFactoryRetrieve theClassMetadatafor all mapped entities.- 指定者:
getAllClassMetadata在接口中SessionFactory- 返回:
- A map containing all
ClassMetadatakeyed by the correspondingStringentity-name. - 抛出:
HibernateException- Generally empty map is returned instead of throwing.
-
getAllCollectionMetadata
public Map getAllCollectionMetadata() throws HibernateException
从接口复制的说明:SessionFactoryGet theCollectionMetadatafor all mapped collections.- 指定者:
getAllCollectionMetadata在接口中SessionFactory- 返回:
- a map from String to CollectionMetadata
- 抛出:
HibernateException- Generally empty map is returned instead of throwing.
-
getReferencedPropertyType
public Type getReferencedPropertyType(String className, String propertyName) throws MappingException
- 指定者:
getReferencedPropertyType在接口中Mapping- 抛出:
MappingException
-
close
public void close() throws HibernateExceptionCloses the session factory, releasing all held resources.- cleans up used cache regions and "stops" the cache provider.
- close the JDBC connection
- remove the JNDI binding
- 指定者:
close在接口中AutoCloseable- 指定者:
close在接口中Closeable- 指定者:
close在接口中javax.persistence.EntityManagerFactory- 指定者:
close在接口中SessionFactory- 抛出:
HibernateException
-
getCache
public CacheImplementor getCache()
从接口复制的说明:SessionFactoryObtain direct access to the underlying cache regions.- 指定者:
getCache在接口中javax.persistence.EntityManagerFactory- 指定者:
getCache在接口中SessionFactory- 指定者:
getCache在接口中SessionFactoryImplementor- 返回:
- The direct cache access API.
-
getPersistenceUnitUtil
public javax.persistence.PersistenceUnitUtil getPersistenceUnitUtil()
- 指定者:
getPersistenceUnitUtil在接口中javax.persistence.EntityManagerFactory
-
addNamedQuery
public void addNamedQuery(String name, javax.persistence.Query query)
- 指定者:
addNamedQuery在接口中javax.persistence.EntityManagerFactory
-
unwrap
public <T> T unwrap(Class<T> type)
- 指定者:
unwrap在接口中javax.persistence.EntityManagerFactory
-
addNamedEntityGraph
public <T> void addNamedEntityGraph(String graphName, javax.persistence.EntityGraph<T> entityGraph)
- 指定者:
addNamedEntityGraph在接口中javax.persistence.EntityManagerFactory
-
isClosed
public boolean isClosed()
从接口复制的说明:SessionFactoryIs this factory already closed?- 指定者:
isClosed在接口中SessionFactory- 返回:
- True if this factory is already closed; false otherwise.
-
getStatistics
public StatisticsImplementor getStatistics()
从接口复制的说明:SessionFactoryRetrieve the statistics for this factory.- 指定者:
getStatistics在接口中SessionFactory- 指定者:
getStatistics在接口中SessionFactoryImplementor- 返回:
- The statistics.
-
getFilterDefinition
public FilterDefinition getFilterDefinition(String filterName) throws HibernateException
从接口复制的说明:SessionFactoryObtain the definition of a filter by name.- 指定者:
getFilterDefinition在接口中SessionFactory- 参数:
filterName- The name of the filter for which to obtain the definition.- 返回:
- The filter definition.
- 抛出:
HibernateException- If no filter defined with the given name.
-
containsFetchProfileDefinition
public boolean containsFetchProfileDefinition(String name)
从接口复制的说明:SessionFactoryDetermine if this session factory contains a fetch profile definition registered under the given name.- 指定者:
containsFetchProfileDefinition在接口中SessionFactory- 参数:
name- The name to check- 返回:
- True if there is such a fetch profile; false otherwise.
-
getDefinedFilterNames
public Set getDefinedFilterNames()
从接口复制的说明:SessionFactoryObtain a set of the names of all filters defined on this SessionFactory.- 指定者:
getDefinedFilterNames在接口中SessionFactory- 返回:
- The set of filter names.
-
getIdentifierGenerator
public IdentifierGenerator getIdentifierGenerator(String rootEntityName)
从接口复制的说明:SessionFactoryImplementorGet the identifier generator for the hierarchy
-
getServiceRegistry
public ServiceRegistryImplementor getServiceRegistry()
从接口复制的说明:SessionFactoryImplementorAccess to the ServiceRegistry for this SessionFactory.- 指定者:
getServiceRegistry在接口中SessionFactoryImplementor- 返回:
- The factory's ServiceRegistry
-
getEntityNotFoundDelegate
public EntityNotFoundDelegate getEntityNotFoundDelegate()
-
getSqlFunctionRegistry
public SQLFunctionRegistry getSqlFunctionRegistry()
-
getFetchProfile
public FetchProfile getFetchProfile(String name)
从接口复制的说明:SessionFactoryImplementorRetrieve fetch profile by name.- 指定者:
getFetchProfile在接口中SessionFactoryImplementor- 参数:
name- The name of the profile to retrieve.- 返回:
- The profile definition
-
getTypeHelper
public TypeHelper getTypeHelper()
从接口复制的说明:SessionFactoryRetrieve this factory'sTypeHelper.- 指定者:
getTypeHelper在接口中SessionFactory- 返回:
- The factory's
TypeHelper
-
configuredInterceptor
public static Interceptor configuredInterceptor(Interceptor interceptor, SessionFactoryOptions options)
-
getCustomEntityDirtinessStrategy
public CustomEntityDirtinessStrategy getCustomEntityDirtinessStrategy()
-
getCurrentTenantIdentifierResolver
public CurrentTenantIdentifierResolver getCurrentTenantIdentifierResolver()
-
-