public class DbThreadSession extends DbSession
DbSession
. Upon creation, it assigns
the session to current thread. Useful when only one session (i.e. connection)
is used per thread, through service layers.
DbThreadSession
uses ThreadDbSessionHolder
for storing
created sessions in the thread storage. Note that holder may be manipulated from outside
of this class.
connection, connectionProvider, queries, txActive, txMode
Constructor and Description |
---|
DbThreadSession()
Creates new db session and assigns it to the current thread, using
default connection provider.
|
DbThreadSession(ConnectionProvider connectionProvider)
Creates new db session and assigns it to the current thread.
|
Modifier and Type | Method and Description |
---|---|
void |
closeSession()
Closes current session and remove the association from current thread.
|
static void |
closeThreadSession()
Closes thread session.
|
static DbSession |
getCurrentSession()
Returns current thread session or
null if no session is assigned
to a thread. |
static DbThreadSession |
getThreadSession()
Returns existing thread session, or new one if already not exist.
|
assertSessionIsOpen, assertTxIsActive, assertTxIsClosed, attachQuery, beginTransaction, close, closeTx, commitTransaction, detachQuery, getConnection, getTotalQueries, isSessionClosed, isSessionOpen, isTransactionActive, openConnectionForQuery, openTx, rollbackTransaction
public DbThreadSession(ConnectionProvider connectionProvider)
connectionProvider
- connection providerpublic DbThreadSession()
public void closeSession()
closeSession
in class DbSession
DbSession.closeSession()
public static DbSession getCurrentSession()
null
if no session is assigned
to a thread.public static DbThreadSession getThreadSession()
public static void closeThreadSession()
Copyright © 2003-present Jodd Team