org.zkoss.zkplus.hibernate
Class OpenSessionInViewListener

java.lang.Object
  extended by org.zkoss.zkplus.hibernate.OpenSessionInViewListener
All Implemented Interfaces:
org.zkoss.zk.ui.util.ExecutionCleanup, org.zkoss.zk.ui.util.ExecutionInit

Deprecated. As of release 6.0.2, please use the official Hibernate's method instead.

public class OpenSessionInViewListener
extends Object
implements org.zkoss.zk.ui.util.ExecutionInit, org.zkoss.zk.ui.util.ExecutionCleanup

Listener to init and cleanup the hibernate session automatically, implement the Hibernate's "Open Session In View" pattern without JTA support. This listener is used with HibernateUtil, or it will not work.

In WEB-INF/zk.xml, add following lines:


        <listener>
                <description>Hibernate "OpenSessionInView" Listener</description>
                <listener-class>org.zkoss.zkplus.hibernate.OpenSessionInViewListener</listener-class>
        </listener>
 

Applicable to Hibernate version 3.2.ga or later

Author:
henrichen

Constructor Summary
OpenSessionInViewListener()
          Deprecated.  
 
Method Summary
 void cleanup(org.zkoss.zk.ui.Execution exec, org.zkoss.zk.ui.Execution parent, List errs)
          Deprecated.  
protected  void handleOtherException(org.zkoss.zk.ui.Execution exec, Throwable ex)
          Deprecated. Default other exception (other than StaleObjectStateException) handler.
protected  void handleStaleObjectStateException(org.zkoss.zk.ui.Execution exec, org.hibernate.StaleObjectStateException ex)
          Deprecated. Default StaleObjectStateException handler.
 void init(org.zkoss.zk.ui.Execution exec, org.zkoss.zk.ui.Execution parent)
          Deprecated.  
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OpenSessionInViewListener

public OpenSessionInViewListener()
Deprecated. 
Method Detail

init

public void init(org.zkoss.zk.ui.Execution exec,
                 org.zkoss.zk.ui.Execution parent)
Deprecated. 
Specified by:
init in interface org.zkoss.zk.ui.util.ExecutionInit

cleanup

public void cleanup(org.zkoss.zk.ui.Execution exec,
                    org.zkoss.zk.ui.Execution parent,
                    List errs)
Deprecated. 
Specified by:
cleanup in interface org.zkoss.zk.ui.util.ExecutionCleanup

handleStaleObjectStateException

protected void handleStaleObjectStateException(org.zkoss.zk.ui.Execution exec,
                                               org.hibernate.StaleObjectStateException ex)
Deprecated. 

Default StaleObjectStateException handler. This implementation does not implement optimistic concurrency control! It simply rollback the transaction.

Application developer might want to extends this class and override this method to do other things like compensate for any permanent changes during the conversation, and finally restart business conversation. Or maybe give the user of the application a chance to merge some of his work with fresh data... what can be done here depends on the applications design.

Parameters:
exec - the execution to clean up.
ex - the StaleObjectStateException being thrown (and not handled) during the execution

handleOtherException

protected void handleOtherException(org.zkoss.zk.ui.Execution exec,
                                    Throwable ex)
Deprecated. 

Default other exception (other than StaleObjectStateException) handler. This implementation simply rollback the transaction.

Application developer might want to extends this class and override this method to do other things like compensate for any permanent changes during the conversation, and finally restart business conversation... what can be done here depends on the applications design.

Parameters:
exec - the execution to clean up.
ex - the Throwable other than StaleObjectStateException being thrown (and not handled) during the execution


Copyright © 2014. All rights reserved.