|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.hibernate.internal.SessionFactoryImpl
public final class SessionFactoryImpl
Concrete implementation of the SessionFactory interface. Has the following responsibilities
ConnectionProvider
,
Session
,
QueryTranslator
,
EntityPersister
,
CollectionPersister
,
Serialized FormNested Class Summary | |
---|---|
static class |
SessionFactoryImpl.StatelessSessionBuilderImpl
|
Nested classes/interfaces inherited from interface org.hibernate.SessionFactory |
---|
SessionFactory.SessionFactoryOptions |
Constructor Summary | |
---|---|
SessionFactoryImpl(Configuration cfg,
Mapping mapping,
ServiceRegistry serviceRegistry,
Settings settings,
SessionFactoryObserver observer)
|
|
SessionFactoryImpl(MetadataImplementor metadata,
SessionFactory.SessionFactoryOptions sessionFactoryOptions,
SessionFactoryObserver observer)
|
Method Summary | |
---|---|
void |
addObserver(SessionFactoryObserver observer)
|
void |
close()
Closes the session factory, releasing all held resources. |
boolean |
containsFetchProfileDefinition(String name)
Determine if this session factory contains a fetch profile definition registered under the given name. |
void |
evict(Class persistentClass)
Evict all entries from the second-level cache. |
void |
evict(Class persistentClass,
Serializable id)
Evict an entry from the second-level cache. |
void |
evictCollection(String roleName)
Evict all entries from the second-level cache. |
void |
evictCollection(String roleName,
Serializable id)
Evict an entry from the second-level cache. |
void |
evictEntity(String entityName)
Evict all entries from the second-level cache. |
void |
evictEntity(String entityName,
Serializable id)
Evict an entry from the second-level cache. |
void |
evictQueries()
Evict any query result sets cached in the default query cache region. |
void |
evictQueries(String regionName)
Evict any query result sets cached in the named query cache region. |
Map<String,ClassMetadata> |
getAllClassMetadata()
Retrieve the ClassMetadata for all mapped entities. |
Map |
getAllCollectionMetadata()
Get the CollectionMetadata for all mapped collections |
Map |
getAllSecondLevelCacheRegions()
Get a map of all the second level cache regions currently maintained in this session factory. |
Cache |
getCache()
Obtain direct access to the underlying cache regions. |
ClassMetadata |
getClassMetadata(Class persistentClass)
Retrieve the ClassMetadata associated with the given entity class. |
ClassMetadata |
getClassMetadata(String entityName)
Retrieve the ClassMetadata associated with the given entity class. |
CollectionMetadata |
getCollectionMetadata(String roleName)
Get the CollectionMetadata associated with the named collection role. |
CollectionPersister |
getCollectionPersister(String role)
Get the persister object for a collection role. |
Set<String> |
getCollectionRolesByEntityParticipant(String entityName)
Retrieves a set of all the collection roles in which the given entity is a participant, as either an index or an element. |
ConnectionProvider |
getConnectionProvider()
Get the connection provider |
Session |
getCurrentSession()
Obtains the current session. |
CurrentTenantIdentifierResolver |
getCurrentTenantIdentifierResolver()
|
CustomEntityDirtinessStrategy |
getCustomEntityDirtinessStrategy()
|
Set |
getDefinedFilterNames()
Obtain a set of the names of all filters defined on this SessionFactory. |
Dialect |
getDialect()
Get the SQL dialect. |
EntityNotFoundDelegate |
getEntityNotFoundDelegate()
|
EntityPersister |
getEntityPersister(String entityName)
Get the persister for the named entity |
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 hierarchy |
IdentifierGeneratorFactory |
getIdentifierGeneratorFactory()
Allow access to the id generator factory, though this is only needed/allowed from configuration. |
String |
getIdentifierPropertyName(String className)
|
Type |
getIdentifierType(String className)
|
String[] |
getImplementors(String className)
Given the name of an entity class, determine all the class and interface names by which it can be referenced in an HQL query. |
String |
getImportedClassName(String className)
Get a class name, using query language imports |
Interceptor |
getInterceptor()
Get the factory scoped interceptor for this factory. |
JdbcServices |
getJdbcServices()
Get the JdbcServices. |
NamedQueryDefinition |
getNamedQuery(String queryName)
|
NamedSQLQueryDefinition |
getNamedSQLQuery(String queryName)
|
Region |
getNaturalIdCacheRegion(String regionName)
Get a named naturalId cache region |
Properties |
getProperties()
Get a copy of the Properties used to configure this session factory. |
QueryCache |
getQueryCache()
Get the default query cache |
QueryCache |
getQueryCache(String regionName)
Get a particular named query cache, or the default cache |
QueryPlanCache |
getQueryPlanCache()
|
Reference |
getReference()
|
Type |
getReferencedPropertyType(String className,
String propertyName)
|
ResultSetMappingDefinition |
getResultSetMapping(String resultSetName)
|
String[] |
getReturnAliases(String queryString)
Get the return aliases of a query |
Type[] |
getReturnTypes(String queryString)
Get the return types of a query |
Region |
getSecondLevelCacheRegion(String regionName)
Get a named second-level cache region |
ServiceRegistryImplementor |
getServiceRegistry()
|
SessionFactory.SessionFactoryOptions |
getSessionFactoryOptions()
|
Settings |
getSettings()
|
SQLExceptionConverter |
getSQLExceptionConverter()
Retrieves the SQLExceptionConverter in effect for this SessionFactory. |
SqlExceptionHelper |
getSQLExceptionHelper()
Retrieves the SqlExceptionHelper in effect for this SessionFactory. |
SQLFunctionRegistry |
getSqlFunctionRegistry()
|
Statistics |
getStatistics()
Retrieve the statistics fopr this factory. |
StatisticsImplementor |
getStatisticsImplementor()
Statistics SPI |
TransactionEnvironment |
getTransactionEnvironment()
|
TypeHelper |
getTypeHelper()
Retrieve this factory's TypeHelper |
TypeResolver |
getTypeResolver()
Retrieve the Type resolver associated with this factory. |
UpdateTimestampsCache |
getUpdateTimestampsCache()
Get the cache of table update timestamps |
boolean |
isClosed()
Is this factory already closed? |
Iterable<EntityNameResolver> |
iterateEntityNameResolvers()
|
Session |
openSession()
Open a Session . |
StatelessSession |
openStatelessSession()
Open a new stateless session. |
StatelessSession |
openStatelessSession(Connection connection)
Open a new stateless session, utilizing the specified JDBC Connection . |
Session |
openTemporarySession()
Get a nontransactional "current" session for Hibernate EntityManager |
void |
registerEntityNameResolver(EntityNameResolver resolver)
|
SessionBuilderImplementor |
withOptions()
Obtain a Session builder. |
StatelessSessionBuilder |
withStatelessOptions()
Obtain a StatelessSession builder. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SessionFactoryImpl(Configuration cfg, Mapping mapping, ServiceRegistry serviceRegistry, Settings settings, SessionFactoryObserver observer) throws HibernateException
HibernateException
public SessionFactoryImpl(MetadataImplementor metadata, SessionFactory.SessionFactoryOptions sessionFactoryOptions, SessionFactoryObserver observer) throws HibernateException
HibernateException
Method Detail |
---|
public Session openSession() throws HibernateException
SessionFactory
Session
.
JDBC connection(s
will be obtained from the
configured ConnectionProvider
as needed
to perform requested work.
openSession
in interface SessionFactory
HibernateException
- Indicates a problem opening the session; pretty rare here.public Session openTemporarySession() throws HibernateException
SessionFactoryImplementor
openTemporarySession
in interface SessionFactoryImplementor
HibernateException
public Session getCurrentSession() throws HibernateException
SessionFactory
CurrentSessionContext
impl configured
for use.
Note that for backwards compatibility, if a CurrentSessionContext
is not configured but JTA is configured this will default to the JTASessionContext
impl.
getCurrentSession
in interface SessionFactory
HibernateException
- Indicates an issue locating a suitable current session.public SessionBuilderImplementor withOptions()
SessionFactory
Session
builder.
withOptions
in interface SessionFactoryImplementor
withOptions
in interface SessionFactory
public StatelessSessionBuilder withStatelessOptions()
SessionFactory
StatelessSession
builder.
withStatelessOptions
in interface SessionFactory
public StatelessSession openStatelessSession()
SessionFactory
openStatelessSession
in interface SessionFactory
public StatelessSession openStatelessSession(Connection connection)
SessionFactory
Connection
.
openStatelessSession
in interface SessionFactory
connection
- Connection provided by the application.
public void addObserver(SessionFactoryObserver observer)
addObserver
in interface SessionFactoryImplementor
public TransactionEnvironment getTransactionEnvironment()
public Properties getProperties()
SessionFactoryImplementor
getProperties
in interface SessionFactoryImplementor
public IdentifierGeneratorFactory getIdentifierGeneratorFactory()
Mapping
getIdentifierGeneratorFactory
in interface Mapping
public TypeResolver getTypeResolver()
SessionFactoryImplementor
Type
resolver associated with this factory.
getTypeResolver
in interface SessionFactoryImplementor
public void registerEntityNameResolver(EntityNameResolver resolver)
public Iterable<EntityNameResolver> iterateEntityNameResolvers()
public QueryPlanCache getQueryPlanCache()
getQueryPlanCache
in interface SessionFactoryImplementor
public EntityPersister getEntityPersister(String entityName) throws MappingException
SessionFactoryImplementor
getEntityPersister
in interface SessionFactoryImplementor
entityName
- The name of the entity for which to retrieve the persister.
MappingException
- Indicates persister could not be found with that name.public CollectionPersister getCollectionPersister(String role) throws MappingException
SessionFactoryImplementor
getCollectionPersister
in interface SessionFactoryImplementor
role
- The role (name) of the collection for which to retrieve the
persister.
MappingException
- Indicates persister could not be found with that role.public Settings getSettings()
getSettings
in interface SessionFactoryImplementor
public SessionFactory.SessionFactoryOptions getSessionFactoryOptions()
getSessionFactoryOptions
in interface SessionFactory
public JdbcServices getJdbcServices()
SessionFactoryImplementor
getJdbcServices
in interface SessionFactoryImplementor
public Dialect getDialect()
SessionFactoryImplementor
getJdbcServices().getDialect()
getDialect
in interface SessionFactoryImplementor
public Interceptor getInterceptor()
SessionFactoryImplementor
getInterceptor
in interface SessionFactoryImplementor
public SQLExceptionConverter getSQLExceptionConverter()
SessionFactoryImplementor
getSQLExceptionConverter
in interface SessionFactoryImplementor
public SqlExceptionHelper getSQLExceptionHelper()
SessionFactoryImplementor
getSQLExceptionHelper
in interface SessionFactoryImplementor
public Set<String> getCollectionRolesByEntityParticipant(String entityName)
SessionFactoryImplementor
getCollectionRolesByEntityParticipant
in interface SessionFactoryImplementor
entityName
- The entity name for which to get the collection roles.
public Reference getReference()
getReference
in interface Referenceable
public NamedQueryDefinition getNamedQuery(String queryName)
getNamedQuery
in interface SessionFactoryImplementor
public NamedSQLQueryDefinition getNamedSQLQuery(String queryName)
getNamedSQLQuery
in interface SessionFactoryImplementor
public ResultSetMappingDefinition getResultSetMapping(String resultSetName)
getResultSetMapping
in interface SessionFactoryImplementor
public Type getIdentifierType(String className) throws MappingException
getIdentifierType
in interface Mapping
MappingException
public String getIdentifierPropertyName(String className) throws MappingException
getIdentifierPropertyName
in interface Mapping
MappingException
public Type[] getReturnTypes(String queryString) throws HibernateException
SessionFactoryImplementor
getReturnTypes
in interface SessionFactoryImplementor
HibernateException
public String[] getReturnAliases(String queryString) throws HibernateException
SessionFactoryImplementor
getReturnAliases
in interface SessionFactoryImplementor
HibernateException
public ClassMetadata getClassMetadata(Class persistentClass) throws HibernateException
SessionFactory
ClassMetadata
associated with the given entity class.
getClassMetadata
in interface SessionFactory
persistentClass
- The entity class
HibernateException
- Generally null is returned instead of throwing.public CollectionMetadata getCollectionMetadata(String roleName) throws HibernateException
SessionFactory
CollectionMetadata
associated with the named collection role.
getCollectionMetadata
in interface SessionFactory
roleName
- The collection role (in form [owning-entity-name].[collection-property-name]).
HibernateException
- Generally null is returned instead of throwing.public ClassMetadata getClassMetadata(String entityName) throws HibernateException
SessionFactory
ClassMetadata
associated with the given entity class.
getClassMetadata
in interface SessionFactory
entityName
- The entity class
HibernateException
- Generally null is returned instead of throwing.public String[] getImplementors(String className) throws MappingException
getImplementors
in interface SessionFactoryImplementor
className
- The name of the entity class
MappingException
public String getImportedClassName(String className)
SessionFactoryImplementor
getImportedClassName
in interface SessionFactoryImplementor
public Map<String,ClassMetadata> getAllClassMetadata() throws HibernateException
SessionFactory
ClassMetadata
for all mapped entities.
getAllClassMetadata
in interface SessionFactory
ClassMetadata
keyed by the
corresponding String
entity-name.
HibernateException
- Generally empty map is returned instead of throwing.public Map getAllCollectionMetadata() throws HibernateException
SessionFactory
CollectionMetadata
for all mapped collections
getAllCollectionMetadata
in interface SessionFactory
HibernateException
- Generally empty map is returned instead of throwing.public Type getReferencedPropertyType(String className, String propertyName) throws MappingException
getReferencedPropertyType
in interface Mapping
MappingException
public ConnectionProvider getConnectionProvider()
SessionFactoryImplementor
getConnectionProvider
in interface SessionFactoryImplementor
public void close() throws HibernateException
close
in interface SessionFactory
HibernateException
public Cache getCache()
SessionFactory
getCache
in interface SessionFactory
public void evictEntity(String entityName, Serializable id) throws HibernateException
SessionFactory
evictEntity
in interface SessionFactory
entityName
- The entity name for which to evict data.id
- The entity id
HibernateException
- Generally will mean that either that
'persisttentClass' did not name a mapped entity or a problem
communicating with underlying cache impl.public void evictEntity(String entityName) throws HibernateException
SessionFactory
evictEntity
in interface SessionFactory
entityName
- The entity name for which to evict data.
HibernateException
- Generally will mean that either that
'persisttentClass' did not name a mapped entity or a problem
communicating with underlying cache impl.public void evict(Class persistentClass, Serializable id) throws HibernateException
SessionFactory
evict
in interface SessionFactory
persistentClass
- The entity class for which to evict data.id
- The entity id
HibernateException
- Generally will mean that either that
'persisttentClass' did not name a mapped entity or a problem
communicating with underlying cache impl.public void evict(Class persistentClass) throws HibernateException
SessionFactory
evict
in interface SessionFactory
persistentClass
- The entity class for which to evict data.
HibernateException
- Generally will mean that either that
'persisttentClass' did not name a mapped entity or a problem
communicating with underlying cache impl.public void evictCollection(String roleName, Serializable id) throws HibernateException
SessionFactory
evictCollection
in interface SessionFactory
roleName
- The name of the collection roleid
- The id of the collection owner
HibernateException
- Generally will mean that either that
'roleName' did not name a mapped collection or a problem
communicating with underlying cache impl.public void evictCollection(String roleName) throws HibernateException
SessionFactory
evictCollection
in interface SessionFactory
roleName
- The name of the collection role whose regions should be evicted
HibernateException
- Generally will mean that either that
'roleName' did not name a mapped collection or a problem
communicating with underlying cache impl.public void evictQueries() throws HibernateException
SessionFactory
evictQueries
in interface SessionFactory
HibernateException
- Indicate a problem communicating with
underlying cache impl.public void evictQueries(String regionName) throws HibernateException
SessionFactory
evictQueries
in interface SessionFactory
regionName
- The named query cache region from which to evict.
HibernateException
- Since a not-found 'cacheRegion' simply no-ops,
this should indicate a problem communicating with underlying cache impl.public UpdateTimestampsCache getUpdateTimestampsCache()
SessionFactoryImplementor
getUpdateTimestampsCache
in interface SessionFactoryImplementor
public QueryCache getQueryCache()
SessionFactoryImplementor
getQueryCache
in interface SessionFactoryImplementor
public QueryCache getQueryCache(String regionName) throws HibernateException
SessionFactoryImplementor
getQueryCache
in interface SessionFactoryImplementor
regionName
- the name of the cache region, or null for the default query cache
HibernateException
public Region getSecondLevelCacheRegion(String regionName)
SessionFactoryImplementor
getSecondLevelCacheRegion
in interface SessionFactoryImplementor
regionName
- The name of the region to retrieve.
public Region getNaturalIdCacheRegion(String regionName)
SessionFactoryImplementor
getNaturalIdCacheRegion
in interface SessionFactoryImplementor
regionName
- The name of the region to retrieve.
public Map getAllSecondLevelCacheRegions()
SessionFactoryImplementor
Region
instances as the values.
getAllSecondLevelCacheRegions
in interface SessionFactoryImplementor
public boolean isClosed()
SessionFactory
isClosed
in interface SessionFactory
public Statistics getStatistics()
SessionFactory
getStatistics
in interface SessionFactory
public StatisticsImplementor getStatisticsImplementor()
SessionFactoryImplementor
getStatisticsImplementor
in interface SessionFactoryImplementor
public FilterDefinition getFilterDefinition(String filterName) throws HibernateException
SessionFactory
getFilterDefinition
in interface SessionFactory
filterName
- The name of the filter for which to obtain the definition.
HibernateException
- If no filter defined with the given name.public boolean containsFetchProfileDefinition(String name)
SessionFactory
containsFetchProfileDefinition
in interface SessionFactory
name
- The name to check
public Set getDefinedFilterNames()
SessionFactory
getDefinedFilterNames
in interface SessionFactory
public IdentifierGenerator getIdentifierGenerator(String rootEntityName)
SessionFactoryImplementor
getIdentifierGenerator
in interface SessionFactoryImplementor
public ServiceRegistryImplementor getServiceRegistry()
getServiceRegistry
in interface SessionFactoryImplementor
public EntityNotFoundDelegate getEntityNotFoundDelegate()
getEntityNotFoundDelegate
in interface SessionFactoryImplementor
public SQLFunctionRegistry getSqlFunctionRegistry()
getSqlFunctionRegistry
in interface SessionFactoryImplementor
public FetchProfile getFetchProfile(String name)
SessionFactoryImplementor
getFetchProfile
in interface SessionFactoryImplementor
name
- The name of the profile to retrieve.
public TypeHelper getTypeHelper()
SessionFactory
TypeHelper
getTypeHelper
in interface SessionFactory
TypeHelper
public CustomEntityDirtinessStrategy getCustomEntityDirtinessStrategy()
getCustomEntityDirtinessStrategy
in interface SessionFactoryImplementor
public CurrentTenantIdentifierResolver getCurrentTenantIdentifierResolver()
getCurrentTenantIdentifierResolver
in interface SessionFactoryImplementor
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |