net.liftweb.transaction.TransactionContext

object TransactionContext

object TransactionContext

 extends TransactionProtocol with Loggable


Manages a thread-local stack of TransactionContexts.

Choose TransactionService implementation by implicit definition of the implementation of choice, e.g. implicit val txService = TransactionServices.AtomikosTransactionService.

Example usage 1:

 for {
   ctx <- TransactionContext.Required
   entity <- updatedEntities
   if !ctx.isRollbackOnly
 } {
   // transactional stuff
   ctx.getEntityManager.merge(entity)
 }
 
Example usage 2:
 val users = for {
   ctx <- TransactionContext.Required
   name <- userNames
 } yield {
   // transactional stuff
   val query = ctx.getEntityManager.createNamedQuery("findUserByName")
   query.setParameter("userName", name)
   query.getSingleResult
 }
 
author
- Jonas Bonér


Companion: TransactionContext

Source: TransactionContext.scala(124)

 Constructors

def this

 Fields

Mandatory.. object Mandatory

 extends TransactionMonad
Never.. object Never

 extends TransactionMonad
NoOpTransactionMonad.. object NoOpTransactionMonad

 extends TransactionMonad
Required.. object Required

 extends TransactionMonad
RequiresNew.. object RequiresNew

 extends TransactionMonad
Supports.. object Supports

 extends TransactionMonad
logger.. protected val logger Logger Loggable

 Methods

!=.. final def !=(arg0 : Any) Boolean Any
!=.. final def !=(arg0 : Object) Boolean AnyRef
==.. final def ==(arg0 : Object) Boolean AnyRef
==.. final def ==(arg0 : Any) Boolean Any
asInstanceOf.. final def asInstanceOf[T0] T0 Any
clone.. protected def clone Object AnyRef
commitOrRollBack.. protected def commitOrRollBack(tm : TransactionManager) Unit TransactionProtocol
eq.. final def eq(arg0 : Object) Boolean AnyRef
equals.. def equals(arg0 : Any) Boolean AnyRef
finalize.. protected def finalize Unit AnyRef
getClass.. final def getClass Class[Any] AnyRef
handleException.. protected def handleException(tm : TransactionManager, e : Exception) Nothing TransactionProtocol
hashCode.. def hashCode Int AnyRef
isInExistingTransaction.. protected def isInExistingTransaction(tm : TransactionManager)
Checks if a transaction is an existing transaction [details]
param
tm - the transaction manager
return
- boolean
Boolean TransactionProtocol
isInstanceOf.. final def isInstanceOf[T0] Boolean Any
isRollbackOnly.. protected def isRollbackOnly(tm : TransactionManager)
Checks if current transaction is set to rollback only [details]
param
tm - the transaction manager
return
- boolean
Boolean TransactionProtocol
ne.. final def ne(arg0 : Object) Boolean AnyRef
notify.. final def notify Unit AnyRef
notifyAll.. final def notifyAll Unit AnyRef
synchronized.. final def synchronized[T0](arg0 : T0) T0 AnyRef
toString.. def toString String AnyRef
wait.. final def wait Unit AnyRef
wait.. final def wait(arg0 : Long) Unit AnyRef
wait.. final def wait(arg0 : Long, arg1 : Int) Unit AnyRef
withTxMandatory.. def withTxMandatory[T](body : => T)
Wraps body in a transaction with MANDATORY semantics [details]

Throws a TransactionRequiredException if there is no transaction active in scope.

T TransactionProtocol
withTxNever.. def withTxNever[T](body : => T)
Wraps body in a transaction with NEVER semantics [details]

Throws a SystemException in case of an existing transaction in scope.

T TransactionProtocol
withTxNotSupported.. def withTxNotSupported[T](body : => T)
Wraps body in a transaction with NOT_SUPPORTED semantics [details]

Suspends existing transaction, invokes body, resumes transaction.

T TransactionProtocol
withTxRequired.. def withTxRequired[T](body : => T)
Wraps body in a transaction with REQUIRED semantics [details]

Creates a new transaction if no transaction is active in scope, else joins the outer transaction.

T TransactionProtocol
withTxRequiresNew.. def withTxRequiresNew[T](body : => T)
Wraps body in a transaction with REQUIRES_NEW semantics [details]

Suspends existing transaction, starts a new transaction, invokes body, commits or rollbacks new transaction, finally resumes previous transaction.

T TransactionProtocol
withTxSupports.. def withTxSupports[T](body : => T)
Wraps body in a transaction with SUPPORTS semantics [details]

Basicalla a No-op.

T TransactionProtocol
Copyright (c) 2006-2011 WorldWide Conferencing, LLC. All Rights Reserved.