Package tenapull.data.persistence
Class Dao.SessionTracker
java.lang.Object
tenapull.data.persistence.Dao.SessionTracker
protected static class Dao.SessionTracker
extends java.lang.Object
Session tracker used to track the daos and invocations that are using an
open session
-
Field Summary
-
Method Summary
Modifier and Type Method Description protected void
done(Dao dao)
The way for a dao to indicate that the current method is finished with its used of this session, so can be removed from the sharers list.protected void
failed(java.lang.Throwable e, Dao dao)
Method to invoke when there is a DB failure.protected org.hibernate.Transaction
getTransaction()
Gets the transaction for the current session, or creates it if one does not yet exist
-
Field Details
-
session
protected final org.hibernate.Session sessionThe Session being tracked -
thread
protected final java.lang.Thread threadThe Thread on which this session is being used -
sharers
All daos which are sharing this session. The same dao may appear multiple times if its methods using the session are being invoked sequentially through the call stack, before it closes its role in the session. The session is not actually closed and the transaction committed until this list has been emptied
-
-
Method Details
-
done
The way for a dao to indicate that the current method is finished with its used of this session, so can be removed from the sharers list. Once the sharers list reaches zero, the session will be closed- Parameters:
dao
- the dao
-
getTransaction
protected org.hibernate.Transaction getTransaction()Gets the transaction for the current session, or creates it if one does not yet exist- Returns:
- the transaction
-
failed
Method to invoke when there is a DB failure. This will rollback the transaction, log the exception, wrap the exception with a DbException, and then throw it back up the call stack.- Parameters:
e
- the edao
- the dao- Throws:
DbException
- the db exception
-