to.etc.domui.hibernate.generic
Class HibernateLongSessionContext

java.lang.Object
  extended by to.etc.webapp.query.QAbstractDataContext
      extended by to.etc.domui.hibernate.generic.BuggyHibernateBaseContext
          extended by to.etc.domui.hibernate.generic.HibernateLongSessionContext
All Implemented Interfaces:
IConversationStateListener, QDataContext

public class HibernateLongSessionContext
extends BuggyHibernateBaseContext

A context that keeps the session alive but in disconnected mode while running. The session is put into MANUAL flush mode, and the database connection is closed every time the conversation is detached. Only the last phase of a conversation may commit and flush changes to the database; all intermediary flushes will be rolled back (and of course Hibernate will not see it because it is utterly stupid).

Author:
Frits Jalvingh Created on Oct 23, 2008

Field Summary
 
Fields inherited from class to.etc.domui.hibernate.generic.BuggyHibernateBaseContext
LOG, m_session, m_sessionMaker
 
Constructor Summary
HibernateLongSessionContext(QDataContextFactory src, HibernateSessionMaker sessionMaker)
           
 
Method Summary
 void attach(java.lang.Object o)
          Should never be used on a long-used context (20091206 jal, error in table update if object not saved 1st).
 void commit()
          Commit; make sure a transaction exists (because nothing is flushed anyway) then commit.
 void conversationAttached(ConversationContext cc)
          
 void conversationDestroyed(ConversationContext cc)
          
 void conversationDetached(ConversationContext cc)
          
 void conversationNew(ConversationContext cc)
          
 Session getSession()
          This override allocates a session in flushmode manual.
 
Methods inherited from class to.etc.domui.hibernate.generic.BuggyHibernateBaseContext
addCommitAction, checkValid, close, getConnection, inTransaction, isIgnoreClose, rollback, runCommitHandlers, setConversationInvalid, setIgnoreClose, setSessionMaker, startTransaction
 
Methods inherited from class to.etc.webapp.query.QAbstractDataContext
delete, find, find, getFactory, getHandlerFactory, getInstance, getInstance, query, query, queryOne, queryOne, refresh, save
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface to.etc.webapp.query.QDataContext
delete, find, find, getFactory, getInstance, getInstance, query, query, queryOne, queryOne, refresh, save
 

Constructor Detail

HibernateLongSessionContext

public HibernateLongSessionContext(QDataContextFactory src,
                                   HibernateSessionMaker sessionMaker)
Method Detail

getSession

public Session getSession()
                   throws java.lang.Exception
This override allocates a session in flushmode manual.

Overrides:
getSession in class BuggyHibernateBaseContext
Returns:
Throws:
java.lang.Exception
See Also:
BuggyHibernateBaseContext.getSession()

conversationDestroyed

public void conversationDestroyed(ConversationContext cc)
                           throws java.lang.Exception
Description copied from class: BuggyHibernateBaseContext

Specified by:
conversationDestroyed in interface IConversationStateListener
Overrides:
conversationDestroyed in class BuggyHibernateBaseContext
Throws:
java.lang.Exception
See Also:
IConversationStateListener.conversationDestroyed(to.etc.domui.state.ConversationContext)

conversationDetached

public void conversationDetached(ConversationContext cc)
                          throws java.lang.Exception
Description copied from class: BuggyHibernateBaseContext

Specified by:
conversationDetached in interface IConversationStateListener
Overrides:
conversationDetached in class BuggyHibernateBaseContext
Throws:
java.lang.Exception
See Also:
IConversationStateListener.conversationDetached(to.etc.domui.state.ConversationContext)

conversationAttached

public void conversationAttached(ConversationContext cc)
                          throws java.lang.Exception
Description copied from class: BuggyHibernateBaseContext

Specified by:
conversationAttached in interface IConversationStateListener
Overrides:
conversationAttached in class BuggyHibernateBaseContext
Throws:
java.lang.Exception

conversationNew

public void conversationNew(ConversationContext cc)
                     throws java.lang.Exception
Description copied from class: BuggyHibernateBaseContext

Specified by:
conversationNew in interface IConversationStateListener
Overrides:
conversationNew in class BuggyHibernateBaseContext
Throws:
java.lang.Exception
See Also:
IConversationStateListener.conversationNew(to.etc.domui.state.ConversationContext)

commit

public void commit()
            throws java.lang.Exception
Commit; make sure a transaction exists (because nothing is flushed anyway) then commit.

Specified by:
commit in interface QDataContext
Overrides:
commit in class BuggyHibernateBaseContext
Throws:
java.lang.Exception
See Also:
BuggyHibernateBaseContext.commit()

attach

public void attach(java.lang.Object o)
            throws java.lang.Exception
Should never be used on a long-used context (20091206 jal, error in table update if object not saved 1st).

Specified by:
attach in interface QDataContext
Overrides:
attach in class QAbstractDataContext
Throws:
java.lang.Exception
See Also:
QAbstractDataContext.attach(java.lang.Object)