net.sourceforge.hivetranse.transaction.hibernate3
Class HibernateTransactionService

java.lang.Object
  extended by net.sourceforge.hivetranse.transaction.AbstractTransactionService
      extended by net.sourceforge.hivetranse.transaction.hibernate3.HibernateTransactionService
All Implemented Interfaces:
TransactionService, org.apache.hivemind.Discardable, org.apache.hivemind.PoolManageable

public class HibernateTransactionService
extends AbstractTransactionService

Service managing Hibernate sessions & transactions, without JTA. This service works hand-in-hand with SessionProxyFactory.

The service supports more than one SessionFactory with the limitation that partial commit or rollback may occur across different databases, because JTA is not used.

If you want correct management of several databases, then better try using JtaTransactionService.

ServiceModel must be threaded

Author:
Jean-Francois Poilpret

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sourceforge.hivetranse.transaction.AbstractTransactionService
AbstractTransactionService.Context, AbstractTransactionService.TransactionObject
 
Field Summary
 
Fields inherited from class net.sourceforge.hivetranse.transaction.AbstractTransactionService
_current, _listeners, _logger, _stack, _wrapRuntimeExceptions
 
Constructor Summary
HibernateTransactionService(org.apache.commons.logging.Log logger, boolean wrapRuntimeExceptions, boolean deferSessionClose, boolean reuseLastSession)
           
 
Method Summary
protected  void cleanUp()
           
protected  java.lang.Object createTransaction()
          Method called when creation of a new "transaction" is needed.
protected  void endTransaction(java.lang.Object tx, boolean commit)
          Method called when the current "transaction" must end, either committed or rolled back.
 
Methods inherited from class net.sourceforge.hivetranse.transaction.AbstractTransactionService
activateService, addTransactionEventListener, begin, beginTransaction, cleanUp, end, fireAfterNewTransactionBegins, fireAfterTransactionEnds, fireBeforeNewTransactionBegins, fireBeforeTransactionEnds, getCurrentTransaction, passivateService, removeTransactionEventListener, setRollbackOnly, storeTransaction, storeTransaction, threadDidDiscardService
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HibernateTransactionService

public HibernateTransactionService(org.apache.commons.logging.Log logger,
                                   boolean wrapRuntimeExceptions,
                                   boolean deferSessionClose,
                                   boolean reuseLastSession)
Method Detail

createTransaction

protected java.lang.Object createTransaction()
                                      throws java.lang.Exception
Description copied from class: AbstractTransactionService
Method called when creation of a new "transaction" is needed. It must be implemented by subclasses.

Please note that "transaction" may be anything and does not have to be just a transaction, ie it may be a JDBC Connection, a Hibernate Session...

Specified by:
createTransaction in class AbstractTransactionService
Returns:
the new transaction created. Internal storage of this object is performed by AbstractTransactionService.
Throws:
java.lang.Exception - any exception, that will eventually be wrapped into an -unchecked- TransactionException

endTransaction

protected void endTransaction(java.lang.Object tx,
                              boolean commit)
                       throws java.lang.Exception
Description copied from class: AbstractTransactionService
Method called when the current "transaction" must end, either committed or rolled back. Ending a transaction may have more meaning than just ending an actual transaction, it may as well mean closing a JDBC Connection, an Hibernate Session...

Specified by:
endTransaction in class AbstractTransactionService
Parameters:
tx - the "transaction" object (ie, the same object returned by createTransaction)
commit - true if the transaction represented by tx must be committed, false if it must be rolled back
Throws:
java.lang.Exception - any exception, that will eventually be wrapped into an -unchecked- TransactionException

cleanUp

protected void cleanUp()
Overrides:
cleanUp in class AbstractTransactionService