to.etc.domui.hibernate.generic
Class BuggyHibernateBaseContext

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

public class BuggyHibernateBaseContext
extends QAbstractDataContext
implements QDataContext, IConversationStateListener

This is a basic Hibernate QDataContext implementation, suitable for being used in DomUI code. This base class implements every QDataContext call but does not do any session lifecycle handling. FIXME 20100310 jal This now supports JDBC queries using the same JDBC context but with a butt-ugly mechanism; it needs to be replaced with some kind of switch proxy implementation later on.

Author:
Frits Jalvingh Created on Jul 15, 2009

Field Summary
protected static org.slf4j.Logger LOG
           
protected  Session m_session
           
protected  HibernateSessionMaker m_sessionMaker
           
 
Method Summary
 void addCommitAction(IRunnable cx)
          Add an action which should be executed after a succesful commit on this context.
protected  void checkValid()
           
 void close()
          This version just delegates to the Factory immediately.
 void commit()
          
 void conversationAttached(ConversationContext cc)
          
 void conversationDestroyed(ConversationContext cc)
          
 void conversationDetached(ConversationContext cc)
          
 void conversationNew(ConversationContext cc)
          
 java.sql.Connection getConnection()
          We explicitly undeprecate here.
 Session getSession()
          INTERNAL USE ONLY Get the Hibernate session present in this QDataContext; allocate a new Session if no session is currently active.
 boolean inTransaction()
          
 boolean isIgnoreClose()
           
 void rollback()
          
protected  void runCommitHandlers()
           
protected  void setConversationInvalid(java.lang.String conversationInvalid)
           
 void setIgnoreClose(boolean on)
          When ignoreClose is set to T the close call must be silently ignored.
protected  void setSessionMaker(HibernateSessionMaker sm)
          Set the Hibernate session maker factory.
 void startTransaction()
          
 
Methods inherited from class to.etc.webapp.query.QAbstractDataContext
attach, 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
attach, delete, find, find, getFactory, getInstance, getInstance, query, query, queryOne, queryOne, refresh, save
 

Field Detail

LOG

protected static final org.slf4j.Logger LOG

m_sessionMaker

protected HibernateSessionMaker m_sessionMaker

m_session

protected Session m_session
Method Detail

setSessionMaker

protected void setSessionMaker(HibernateSessionMaker sm)
Set the Hibernate session maker factory.

Parameters:
sm -

getSession

public Session getSession()
                   throws java.lang.Exception
INTERNAL USE ONLY Get the Hibernate session present in this QDataContext; allocate a new Session if no session is currently active. This is not supposed to be called by user code.

Returns:
Throws:
java.lang.Exception

checkValid

protected void checkValid()

setConversationInvalid

protected void setConversationInvalid(java.lang.String conversationInvalid)

setIgnoreClose

public void setIgnoreClose(boolean on)
When ignoreClose is set to T the close call must be silently ignored. Ugly, but for a lot of reasons (all having to do with the very strained object model around the ViewPoint database code) this is the least invasive method to allow for per-conversation shared contexts. Please do not replace this with any kind of wrapper/proxy based solution; it will not work.

Specified by:
setIgnoreClose in interface QDataContext
See Also:
QDataContext.setIgnoreClose(boolean)

isIgnoreClose

public boolean isIgnoreClose()

close

public void close()
This version just delegates to the Factory immediately. This will close and fully discard all resources belonging to this context, provided ignoreClose is not true. A closed context cannot be reused anymore and should be discarded.

Specified by:
close in interface QDataContext
See Also:
QDataContext.close()

startTransaction

public void startTransaction()
                      throws java.lang.Exception

Specified by:
startTransaction in interface QDataContext
Throws:
java.lang.Exception
See Also:
QDataContext.startTransaction()

commit

public void commit()
            throws java.lang.Exception

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

runCommitHandlers

protected void runCommitHandlers()
                          throws java.lang.Exception
Throws:
java.lang.Exception

inTransaction

public boolean inTransaction()
                      throws java.lang.Exception

Specified by:
inTransaction in interface QDataContext
Throws:
java.lang.Exception
See Also:
QDataContext.inTransaction()

rollback

public void rollback()
              throws java.lang.Exception

Specified by:
rollback in interface QDataContext
Throws:
java.lang.Exception
See Also:
QDataContext.rollback()

getConnection

public java.sql.Connection getConnection()
                                  throws java.lang.Exception
We explicitly undeprecate here.

Specified by:
getConnection in interface QDataContext
Throws:
java.lang.Exception
See Also:
QDataContext.getConnection()

addCommitAction

public void addCommitAction(IRunnable cx)
Description copied from interface: QDataContext
Add an action which should be executed after a succesful commit on this context.

Specified by:
addCommitAction in interface QDataContext

conversationAttached

public void conversationAttached(ConversationContext cc)
                          throws java.lang.Exception

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

conversationDestroyed

public void conversationDestroyed(ConversationContext cc)
                           throws java.lang.Exception

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

conversationDetached

public void conversationDetached(ConversationContext cc)
                          throws java.lang.Exception

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

conversationNew

public void conversationNew(ConversationContext cc)
                     throws java.lang.Exception

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