|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jodd.db.DbSession
public class DbSession
Encapsulates db connection. Initially works in auto-commit mode. May start and work with transactions, after commiting/rolling back DbSession goes back to auto-commit mode.
All invoked queries are stored within one session and closed implicitly on session closing.
For managed transaction see DbJtxTransactionManager
.
Field Summary | |
---|---|
protected java.sql.Connection |
connection
|
protected ConnectionProvider |
connectionProvider
|
static DbTransactionMode |
DEFAULT_TX_MODE
Default DbTransactionMode for all db sessions. |
protected java.util.Set<DbQuery> |
queries
Bag of all queries attached to this session. |
protected boolean |
txActive
|
protected DbTransactionMode |
txMode
|
Constructor Summary | |
---|---|
DbSession(ConnectionProvider connectionProvider)
Creates new database session with default transaction mode and in autocommit mode. |
Method Summary | |
---|---|
void |
beginTransaction()
Starts transaction with default transaction mode. |
void |
beginTransaction(DbTransactionMode mode)
Starts a transaction. |
protected void |
checkActiveTx()
|
protected void |
checkClosedTx()
|
protected void |
checkOpenSession()
|
void |
closeSession()
Closes current session and all allocated resources. |
protected void |
closeTx()
Closes current transaction. |
void |
commitTransaction()
Commit the current transaction, writing any unflushed changes to the database. |
java.sql.Connection |
getConnection()
Returns current connection. |
int |
getTotalActiveQueries()
Returns total number of queries assigned to this session. |
int |
getTotalQueries()
Returns total number of queries assigned to this session. |
boolean |
isSessionClosed()
Indicates whether a session is open. |
boolean |
isTransactionActive()
Indicate whether a transaction is in progress. |
protected void |
openConnectionForQuery()
Opens connection in autocommit mode, if already not opened. |
protected void |
openTx()
Opens a transaction. |
void |
rollbackTransaction()
Roll back the current transaction. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static DbTransactionMode DEFAULT_TX_MODE
DbTransactionMode
for all db sessions.
protected final ConnectionProvider connectionProvider
protected java.sql.Connection connection
protected java.util.Set<DbQuery> queries
null
session is closed;
protected boolean txActive
protected DbTransactionMode txMode
Constructor Detail |
---|
public DbSession(ConnectionProvider connectionProvider)
Method Detail |
---|
public void closeSession()
ConnectionProvider
.
Closed session is no longer available for usage.
public boolean isSessionClosed()
public int getTotalQueries()
public int getTotalActiveQueries()
public java.sql.Connection getConnection()
attachQuery(DbQuery)
protected void openConnectionForQuery()
public boolean isTransactionActive()
protected void openTx()
protected void closeTx()
public void beginTransaction(DbTransactionMode mode)
public void beginTransaction()
public void commitTransaction()
public void rollbackTransaction()
protected void checkOpenSession()
protected void checkClosedTx()
protected void checkActiveTx()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |