|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface SessionContext
Defines methods for session handling. This includes methods to start and stop a session as well as retrieving the current database connection and user transaction.
A session context is created by a session context factory.
A session context creates a separate session for each calling thread. Therefore session can not be shared between sessions.
A SessionContext can be used in the following way:
// get the default session context SessionContext ctx = SessionContextFactory.getContext(); // start a new session ctx.startSession(); // start a new transaction ctx.getUserTransaction().begin(); // get the database connection for the current session Connection con = ctx.getConnection(); // do something with the connection ... // commit and end the current transaction ctx.getUserTransaction().commit(); // stop the session ctx.stopSession();
SessionContextFactory,
UserTransaction| Field Summary | |
|---|---|
static String |
DEFAULT_CONTEXT_NAME
Name of the default session context. |
| Method Summary | |
|---|---|
Connection |
getConnection()
Returns the database connection of the session belonging to the calling thread. |
UserTransaction |
getUserTransaction()
Returns the user transaction of the session belonging to the calling thread. |
void |
startSession()
This method starts a session. |
void |
stopSession()
This method stops a session. |
| Field Detail |
|---|
static final String DEFAULT_CONTEXT_NAME
| Method Detail |
|---|
void startSession()
throws SystemException
SystemException - Thrown if an unexpected error condition occurs
IllegalStateException - Thrown if the session is already started
void stopSession()
throws SystemException
SystemException - Thrown if an unexpected error condition occurs
IllegalStateException - Thrown if the session is already stoppedUserTransaction getUserTransaction()
IllegalStateException - Thrown if the session is not startedConnection getConnection()
IllegalStateException - Thrown if the session is not started
|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||