org.hibernate.impl

Class SessionFactoryImpl

Implemented Interfaces:
Referenceable, Serializable, Mapping, SessionFactory, SessionFactoryImplementor

public final class SessionFactoryImpl
extends java.lang.Object
implements SessionFactory, SessionFactoryImplementor

Concrete implementation of the SessionFactory interface. Has the following responsibilites This class must appear immutable to clients, even if it does all kinds of caching and pooling under the covers. It is crucial that the class is not only thread safe, but also highly concurrent. Synchronization must be used extremely sparingly.
Author:
Gavin King
See Also:
ConnectionProvider, Session, QueryTranslator, EntityPersister, CollectionPersister

Constructor Summary

SessionFactoryImpl(Configuration cfg, Mapping mapping, Settings settings, EventListeners listeners, SessionFactoryObserver observer)

Method Summary

void
close()
Closes the session factory, releasing all held resources.
void
evict(Class persistentClass)
void
evict(Class persistentClass, Serializable id)
void
evictCollection(String roleName)
void
evictCollection(String roleName, Serializable id)
void
evictEntity(String entityName)
void
evictEntity(String entityName, Serializable id)
void
evictQueries()
void
evictQueries(String cacheRegion)
Map
getAllClassMetadata()
Map
getAllCollectionMetadata()
Map
getAllSecondLevelCacheRegions()
BatcherFactory
getBatcherFactory()
ClassMetadata
getClassMetadata(Class persistentClass)
ClassMetadata
getClassMetadata(String entityName)
CollectionMetadata
getCollectionMetadata(String roleName)
CollectionPersister
getCollectionPersister(String role)
Set
getCollectionRolesByEntityParticipant(String entityName)
ConnectionProvider
getConnectionProvider()
Session
getCurrentSession()
Set
getDefinedFilterNames()
Dialect
getDialect()
EntityNotFoundDelegate
getEntityNotFoundDelegate()
EntityPersister
getEntityPersister(String entityName)
EventListeners
getEventListeners()
FilterDefinition
getFilterDefinition(String filterName)
IdentifierGenerator
getIdentifierGenerator(String rootEntityName)
String
getIdentifierPropertyName(String className)
Type
getIdentifierType(String className)
String[]
getImplementors(String className)
Return 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.
String
getImportedClassName(String className)
Interceptor
getInterceptor()
NamedQueryDefinition
getNamedQuery(String queryName)
NamedSQLQueryDefinition
getNamedSQLQuery(String queryName)
QueryCache
getQueryCache()
QueryCache
getQueryCache(String regionName)
QueryPlanCache
getQueryPlanCache()
Reference
getReference()
Type
getReferencedPropertyType(String className, String propertyName)
ResultSetMappingDefinition
getResultSetMapping(String resultSetName)
String[]
getReturnAliases(String queryString)
Type[]
getReturnTypes(String queryString)
SQLExceptionConverter
getSQLExceptionConverter()
Region
getSecondLevelCacheRegion(String regionName)
Settings
getSettings()
SQLFunctionRegistry
getSqlFunctionRegistry()
Statistics
getStatistics()
StatisticsImplementor
getStatisticsImplementor()
TransactionFactory
getTransactionFactory()
TransactionManager
getTransactionManager()
UpdateTimestampsCache
getUpdateTimestampsCache()
boolean
isClosed()
Session
openSession()
Session
openSession(Connection connection)
Session
openSession(Connection connection, boolean flushBeforeCompletionEnabled, boolean autoCloseSessionEnabled, ConnectionReleaseMode connectionReleaseMode)
Session
openSession(Connection connection, Interceptor sessionLocalInterceptor)
Session
openSession(Interceptor sessionLocalInterceptor)
StatelessSession
openStatelessSession()
StatelessSession
openStatelessSession(Connection connection)
Session
openTemporarySession()

Constructor Details

SessionFactoryImpl

public SessionFactoryImpl(Configuration cfg,
                          Mapping mapping,
                          Settings settings,
                          EventListeners listeners,
                          SessionFactoryObserver observer)
            throws HibernateException

Method Details

close

public void close()
            throws HibernateException
Closes the session factory, releasing all held resources.
  1. cleans up used cache regions and "stops" the cache provider.
  2. close the JDBC connection
  3. remove the JNDI binding
Note: Be aware that the sessionfactory instance still can be a "heavy" object memory wise after close() has been called. Thus it is important to not keep referencing the instance to let the garbage collector release the memory.
Specified by:
close in interface SessionFactory

evict

public void evict(Class persistentClass)
            throws HibernateException
Specified by:
evict in interface SessionFactory

evict

public void evict(Class persistentClass,
                  Serializable id)
            throws HibernateException
Specified by:
evict in interface SessionFactory

evictCollection

public void evictCollection(String roleName)
            throws HibernateException
Specified by:
evictCollection in interface SessionFactory

evictCollection

public void evictCollection(String roleName,
                            Serializable id)
            throws HibernateException
Specified by:
evictCollection in interface SessionFactory

evictEntity

public void evictEntity(String entityName)
            throws HibernateException
Specified by:
evictEntity in interface SessionFactory

evictEntity

public void evictEntity(String entityName,
                        Serializable id)
            throws HibernateException
Specified by:
evictEntity in interface SessionFactory

evictQueries

public void evictQueries()
            throws HibernateException
Specified by:
evictQueries in interface SessionFactory

evictQueries

public void evictQueries(String cacheRegion)
            throws HibernateException
Specified by:
evictQueries in interface SessionFactory

getAllClassMetadata

public Map getAllClassMetadata()
            throws HibernateException
Specified by:
getAllClassMetadata in interface SessionFactory

getAllCollectionMetadata

public Map getAllCollectionMetadata()
            throws HibernateException
Specified by:
getAllCollectionMetadata in interface SessionFactory

getAllSecondLevelCacheRegions

public Map getAllSecondLevelCacheRegions()
Specified by:
getAllSecondLevelCacheRegions in interface SessionFactoryImplementor

getBatcherFactory

public BatcherFactory getBatcherFactory()

getClassMetadata

public ClassMetadata getClassMetadata(Class persistentClass)
            throws HibernateException
Specified by:
getClassMetadata in interface SessionFactory

getClassMetadata

public ClassMetadata getClassMetadata(String entityName)
            throws HibernateException
Specified by:
getClassMetadata in interface SessionFactory

getCollectionMetadata

public CollectionMetadata getCollectionMetadata(String roleName)
            throws HibernateException
Specified by:
getCollectionMetadata in interface SessionFactory

getCollectionPersister

public CollectionPersister getCollectionPersister(String role)
            throws MappingException
Specified by:
getCollectionPersister in interface SessionFactoryImplementor

getCollectionRolesByEntityParticipant

public Set getCollectionRolesByEntityParticipant(String entityName)
Specified by:
getCollectionRolesByEntityParticipant in interface SessionFactoryImplementor

getConnectionProvider

public ConnectionProvider getConnectionProvider()
Specified by:
getConnectionProvider in interface SessionFactoryImplementor

getCurrentSession

public Session getCurrentSession()
            throws HibernateException
Specified by:
getCurrentSession in interface SessionFactory

getDefinedFilterNames

public Set getDefinedFilterNames()
Specified by:
getDefinedFilterNames in interface SessionFactory

getDialect

public Dialect getDialect()
Specified by:
getDialect in interface SessionFactoryImplementor

getEntityNotFoundDelegate

public EntityNotFoundDelegate getEntityNotFoundDelegate()
Specified by:
getEntityNotFoundDelegate in interface SessionFactoryImplementor

getEntityPersister

public EntityPersister getEntityPersister(String entityName)
            throws MappingException
Specified by:
getEntityPersister in interface SessionFactoryImplementor

getEventListeners

public EventListeners getEventListeners()

getFilterDefinition

public FilterDefinition getFilterDefinition(String filterName)
            throws HibernateException
Specified by:
getFilterDefinition in interface SessionFactory

getIdentifierGenerator

public IdentifierGenerator getIdentifierGenerator(String rootEntityName)
Specified by:
getIdentifierGenerator in interface SessionFactoryImplementor

getIdentifierPropertyName

public String getIdentifierPropertyName(String className)
            throws MappingException
Specified by:
getIdentifierPropertyName in interface Mapping

getIdentifierType

public Type getIdentifierType(String className)
            throws MappingException
Specified by:
getIdentifierType in interface Mapping

getImplementors

public String[] getImplementors(String className)
            throws MappingException
Return 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.
Specified by:
getImplementors in interface SessionFactoryImplementor

getImportedClassName

public String getImportedClassName(String className)
Specified by:
getImportedClassName in interface SessionFactoryImplementor

getInterceptor

public Interceptor getInterceptor()
Specified by:
getInterceptor in interface SessionFactoryImplementor

getNamedQuery

public NamedQueryDefinition getNamedQuery(String queryName)
Specified by:
getNamedQuery in interface SessionFactoryImplementor

getNamedSQLQuery

public NamedSQLQueryDefinition getNamedSQLQuery(String queryName)
Specified by:
getNamedSQLQuery in interface SessionFactoryImplementor

getQueryCache

public QueryCache getQueryCache()
Specified by:
getQueryCache in interface SessionFactoryImplementor

getQueryCache

public QueryCache getQueryCache(String regionName)
            throws HibernateException
Specified by:
getQueryCache in interface SessionFactoryImplementor

getQueryPlanCache

public QueryPlanCache getQueryPlanCache()
Specified by:
getQueryPlanCache in interface SessionFactoryImplementor

getReference

public Reference getReference()
            throws NamingException

getReferencedPropertyType

public Type getReferencedPropertyType(String className,
                                      String propertyName)
            throws MappingException
Specified by:
getReferencedPropertyType in interface Mapping

getResultSetMapping

public ResultSetMappingDefinition getResultSetMapping(String resultSetName)
Specified by:
getResultSetMapping in interface SessionFactoryImplementor

getReturnAliases

public String[] getReturnAliases(String queryString)
            throws HibernateException
Specified by:
getReturnAliases in interface SessionFactoryImplementor

getReturnTypes

public Type[] getReturnTypes(String queryString)
            throws HibernateException
Specified by:
getReturnTypes in interface SessionFactoryImplementor

getSQLExceptionConverter

public SQLExceptionConverter getSQLExceptionConverter()
Specified by:
getSQLExceptionConverter in interface SessionFactoryImplementor

getSecondLevelCacheRegion

public Region getSecondLevelCacheRegion(String regionName)
Specified by:
getSecondLevelCacheRegion in interface SessionFactoryImplementor

getSettings

public Settings getSettings()
Specified by:
getSettings in interface SessionFactoryImplementor

getSqlFunctionRegistry

public SQLFunctionRegistry getSqlFunctionRegistry()
Specified by:
getSqlFunctionRegistry in interface SessionFactoryImplementor

getStatistics

public Statistics getStatistics()
Specified by:
getStatistics in interface SessionFactory

getStatisticsImplementor

public StatisticsImplementor getStatisticsImplementor()
Specified by:
getStatisticsImplementor in interface SessionFactoryImplementor

getTransactionFactory

public TransactionFactory getTransactionFactory()

getTransactionManager

public TransactionManager getTransactionManager()
Specified by:
getTransactionManager in interface SessionFactoryImplementor

getUpdateTimestampsCache

public UpdateTimestampsCache getUpdateTimestampsCache()
Specified by:
getUpdateTimestampsCache in interface SessionFactoryImplementor

isClosed

public boolean isClosed()
Specified by:
isClosed in interface SessionFactory

openSession

public Session openSession()
            throws HibernateException
Specified by:
openSession in interface SessionFactory

openSession

public Session openSession(Connection connection)
Specified by:
openSession in interface SessionFactory

openSession

public Session openSession(Connection connection,
                           boolean flushBeforeCompletionEnabled,
                           boolean autoCloseSessionEnabled,
                           ConnectionReleaseMode connectionReleaseMode)
            throws HibernateException
Specified by:
openSession in interface SessionFactoryImplementor

openSession

public Session openSession(Connection connection,
                           Interceptor sessionLocalInterceptor)
Specified by:
openSession in interface SessionFactory

openSession

public Session openSession(Interceptor sessionLocalInterceptor)
            throws HibernateException
Specified by:
openSession in interface SessionFactory

openStatelessSession

public StatelessSession openStatelessSession()
Specified by:
openStatelessSession in interface SessionFactory

openStatelessSession

public StatelessSession openStatelessSession(Connection connection)
Specified by:
openStatelessSession in interface SessionFactory

openTemporarySession

public Session openTemporarySession()
            throws HibernateException
Specified by:
openTemporarySession in interface SessionFactoryImplementor