Session associated with a well-defined "context" or "scope",
providing the concrete implementation behind the notion of the
current session.
The lifecycle of the context/scope is not specified by Hibernate, and varies depending on the nature of the program. The only hard restriction is that the scope must be single-threaded. On the other hand, since state tends to build up in the first-level cache of session, sessions should typically not be associated with long-lived scopes.
The most typical example of a scope with which a current session might be associated is the HTTP request context in a web application.
An implementation of this interface must:
org.hibernate.engine.spi.SessionFactoryImplementor ,
destroys every session it
creates, and
Every session factory has exactly one instance of this interface.
An implementation may be selected by setting the configuration property hibernate.current_session_context_class.
org.hibernate.SessionFactory#getCurrentSession() , org.hibernate.cfg.AvailableSettings#CURRENT_SESSION_CONTEXT_CLASS
| Modifier and Type | Method and Description |
|---|---|
| public Session | Returns: The current session.Retrieve the current session according to the scoping defined by this implementation. |
| currentSession | back to summary |
|---|---|
| public Session currentSession() throws HibernateException Retrieve the current session according to the scoping defined by this implementation.
| |