Class Dao.SessionTracker

java.lang.Object
tenapull.data.persistence.Dao.SessionTracker
Enclosing class:
Dao<POJO extends DbPojo>

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

    Fields 
    Modifier and Type Field Description
    protected org.hibernate.Session session
    The Session being tracked
    protected java.util.List<Dao> sharers
    All daos which are sharing this session.
    protected java.lang.Thread thread
    The Thread on which this session is being used
  • 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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • session

      protected final org.hibernate.Session session
      The Session being tracked
    • thread

      protected final java.lang.Thread thread
      The Thread on which this session is being used
    • sharers

      protected java.util.List<Dao> 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

      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. 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

      protected void failed​(java.lang.Throwable e, Dao dao) throws DbException
      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 e
      dao - the dao
      Throws:
      DbException - the db exception