|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface SessionFactory
The main contract here is the creation of Session
instances. Usually
an application has a single SessionFactory
instance and threads
servicing client requests obtain Session
instances from this factory.
SessionFactory
is immutable. Once it is created
this internal state is set. This internal state includes all of the metadata
about Object/Relational Mapping.
Implementors must be threadsafe.
Configuration
Method Summary | |
---|---|
void |
close()
Destroy this SessionFactory and release all resources (caches, connection pools, etc). |
boolean |
containsFetchProfileDefinition(String name)
Determine if this session factory contains a fetch profile definition registered under the given name. |
void |
evict(Class persistentClass)
Deprecated. Use Cache.evictEntityRegion(Class) accessed through
getCache() instead. |
void |
evict(Class persistentClass,
Serializable id)
Deprecated. Use Cache.containsEntity(Class, Serializable) accessed through
getCache() instead. |
void |
evictCollection(String roleName)
Deprecated. Use Cache.evictCollectionRegion(String) accessed through
getCache() instead. |
void |
evictCollection(String roleName,
Serializable id)
Deprecated. Use Cache.evictCollection(String,Serializable) accessed through
getCache() instead. |
void |
evictEntity(String entityName)
Deprecated. Use Cache.evictEntityRegion(String) accessed through
getCache() instead. |
void |
evictEntity(String entityName,
Serializable id)
Deprecated. Use Cache.evictEntity(String,Serializable) accessed through
getCache() instead. |
void |
evictQueries()
Deprecated. Use Cache.evictQueryRegions() accessed through
getCache() instead. |
void |
evictQueries(String cacheRegion)
Deprecated. Use Cache.evictQueryRegion(String) accessed through
getCache() instead. |
Map<String,ClassMetadata> |
getAllClassMetadata()
Retrieve the ClassMetadata for all mapped entities. |
Map |
getAllCollectionMetadata()
Get the CollectionMetadata for all mapped collections |
Cache |
getCache()
Obtain direct access to the underlying cache regions. |
ClassMetadata |
getClassMetadata(Class entityClass)
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. |
Session |
getCurrentSession()
Obtains the current session. |
Set |
getDefinedFilterNames()
Obtain a set of the names of all filters defined on this SessionFactory. |
FilterDefinition |
getFilterDefinition(String filterName)
Obtain the definition of a filter by name. |
Statistics |
getStatistics()
Retrieve the statistics fopr this factory. |
TypeHelper |
getTypeHelper()
Retrieve this factory's TypeHelper |
boolean |
isClosed()
Is this factory already closed? |
Session |
openSession()
Open a Session . |
Session |
openSession(Connection connection)
Open a Session , utilizing the specfied JDBC Connection . |
Session |
openSession(Connection connection,
Interceptor interceptor)
Open a Session , utilizing the specfied JDBC Connection and
specified Interceptor . |
Session |
openSession(Interceptor interceptor)
Open a Session , utilizing the specified Interceptor . |
StatelessSession |
openStatelessSession()
Open a new stateless session. |
StatelessSession |
openStatelessSession(Connection connection)
Open a new stateless session, utilizing the specified JDBC Connection . |
Methods inherited from interface javax.naming.Referenceable |
---|
getReference |
Method Detail |
---|
Session openSession() throws HibernateException
Session
.
JDBC connection(s
will be obtained from the
configured ConnectionProvider
as needed
to perform requested work.
HibernateException
- Indicates a peroblem opening the session; pretty rare here.Session openSession(Interceptor interceptor) throws HibernateException
Session
, utilizing the specified Interceptor
.
JDBC connection(s
will be obtained from the
configured ConnectionProvider
as needed
to perform requested work.
interceptor
- a session-scoped interceptor
HibernateException
- Indicates a peroblem opening the session; pretty rare here.Session openSession(Connection connection)
Session
, utilizing the specfied JDBC Connection
.
Note that the second-level cache will be disabled if you supply a JDBC
connection. Hibernate will not be able to track any statements you might
have executed in the same transaction. Consider implementing your own
ConnectionProvider
instead as a highly
recommended alternative.
connection
- a connection provided by the application.
Session openSession(Connection connection, Interceptor interceptor)
Session
, utilizing the specfied JDBC Connection
and
specified Interceptor
.
Note that the second-level cache will be disabled if you supply a JDBC
connection. Hibernate will not be able to track any statements you might
have executed in the same transaction. Consider implementing your own
ConnectionProvider
instead as a highly
recommended alternative.
connection
- a connection provided by the application.interceptor
- a session-scoped interceptor
Session getCurrentSession() throws HibernateException
CurrentSessionContext
impl configured
for use.
Note that for backwards compatibility, if a CurrentSessionContext
is not configured but a JTA TransactionManagerLookup
is configured this will default to the JTASessionContext
impl.
HibernateException
- Indicates an issue locating a suitable current session.StatelessSession openStatelessSession()
StatelessSession openStatelessSession(Connection connection)
Connection
.
connection
- Connection provided by the application.
ClassMetadata getClassMetadata(Class entityClass)
ClassMetadata
associated with the given entity class.
entityClass
- The entity class
HibernateException
- Generally null is returned instead of throwing.ClassMetadata getClassMetadata(String entityName)
ClassMetadata
associated with the given entity class.
entityName
- The entity class
HibernateException
- Generally null is returned instead of throwing.CollectionMetadata getCollectionMetadata(String roleName)
CollectionMetadata
associated with the named collection role.
roleName
- The collection role (in form [owning-entity-name].[collection-property-name]).
HibernateException
- Generally null is returned instead of throwing.Map<String,ClassMetadata> getAllClassMetadata()
ClassMetadata
for all mapped entities.
ClassMetadata
keyed by the
corresponding String
entity-name.
HibernateException
- Generally empty map is returned instead of throwing.Class
to String
.Map getAllCollectionMetadata()
CollectionMetadata
for all mapped collections
HibernateException
- Generally empty map is returned instead of throwing.Statistics getStatistics()
void close() throws HibernateException
sessions
before calling this method as the impact
on those sessions
is indeterminate.
No-ops if already closed
.
HibernateException
- Indicates an issue closing the factory.boolean isClosed()
Cache getCache()
void evict(Class persistentClass) throws HibernateException
Cache.evictEntityRegion(Class)
accessed through
getCache()
instead.
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.void evict(Class persistentClass, Serializable id) throws HibernateException
Cache.containsEntity(Class, Serializable)
accessed through
getCache()
instead.
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.void evictEntity(String entityName) throws HibernateException
Cache.evictEntityRegion(String)
accessed through
getCache()
instead.
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.void evictEntity(String entityName, Serializable id) throws HibernateException
Cache.evictEntity(String,Serializable)
accessed through
getCache()
instead.
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.void evictCollection(String roleName) throws HibernateException
Cache.evictCollectionRegion(String)
accessed through
getCache()
instead.
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.void evictCollection(String roleName, Serializable id) throws HibernateException
Cache.evictCollection(String,Serializable)
accessed through
getCache()
instead.
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.void evictQueries(String cacheRegion) throws HibernateException
Cache.evictQueryRegion(String)
accessed through
getCache()
instead.
cacheRegion
- 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.void evictQueries() throws HibernateException
Cache.evictQueryRegions()
accessed through
getCache()
instead.
HibernateException
- Indicate a problem communicating with
underlying cache impl.Set getDefinedFilterNames()
FilterDefinition getFilterDefinition(String filterName) throws HibernateException
filterName
- The name of the filter for which to obtain the definition.
HibernateException
- If no filter defined with the given name.boolean containsFetchProfileDefinition(String name)
name
- The name to check
TypeHelper getTypeHelper()
TypeHelper
TypeHelper
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |