com.avaje.ebean
Class TxScope

java.lang.Object
  extended by com.avaje.ebean.TxScope

public final class TxScope
extends Object

Holds the definition of how a transactional method should run.

This information matches the features of the Transactional annotation. You can use it directly with TxRunnable or TxCallable via Ebean.execute(TxScope, TxCallable) or Ebean.execute(TxScope, TxRunnable).

This object is used internally with the enhancement of a method with Transactional annotation.

See Also:
TxCallable, TxRunnable, Ebean.execute(TxScope, TxCallable), Ebean.execute(TxScope, TxRunnable)

Constructor Summary
TxScope()
          Create a REQUIRED transaction scope.
TxScope(TxType type)
          Create with a given transaction scope type.
 
Method Summary
 TxIsolation getIsolation()
          Return the Isolation level this transaction should run with.
 ArrayList<Class<? extends Throwable>> getNoRollbackFor()
          Return the throwable's that should NOT cause a rollback.
 ArrayList<Class<? extends Throwable>> getRollbackFor()
          Return the throwable's that should cause a rollback.
 String getServerName()
          Return the serverName for this transaction.
 TxType getType()
          Return the transaction type.
 boolean isReadonly()
          Return if the transaction should be treated as read only.
static TxScope mandatory()
          Helper method to create a TxScope with MANDATORY.
static TxScope never()
          Helper method to create a TxScope with NEVER.
static TxScope notSupported()
          Helper method to create a TxScope with NOT_SUPPORTED.
static TxScope required()
          Helper method to create a TxScope with REQUIRES.
static TxScope requiresNew()
          Helper method to create a TxScope with REQUIRES_NEW.
 TxScope setIsolation(TxIsolation isolation)
          Set the transaction isolation level this transaction should run with.
 TxScope setNoRollbackFor(Class<?>[] noRollbacks)
          Set multiple throwable's that will NOT cause a rollback.
 TxScope setNoRollbackFor(Class<? extends Throwable> noRollback)
          Add a Throwable to a list that will NOT cause a rollback.
 TxScope setReadOnly(boolean readOnly)
          Set if the transaction should be treated as read only.
 TxScope setRollbackFor(Class<?>[] rollbackThrowables)
          Set multiple throwable's that will cause a rollback.
 TxScope setRollbackFor(Class<? extends Throwable> rollbackThrowable)
          Set a Throwable that should explicitly cause a rollback.
 TxScope setServerName(String serverName)
          Set the serverName (DataSource name) for which this transaction will be.
 TxScope setType(TxType type)
          Set the transaction type.
static TxScope supports()
          Helper method to create a TxScope with SUPPORTS.
 String toString()
          Describes this TxScope instance.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TxScope

public TxScope()
Create a REQUIRED transaction scope.


TxScope

public TxScope(TxType type)
Create with a given transaction scope type.

Method Detail

required

public static TxScope required()
Helper method to create a TxScope with REQUIRES.


requiresNew

public static TxScope requiresNew()
Helper method to create a TxScope with REQUIRES_NEW.


mandatory

public static TxScope mandatory()
Helper method to create a TxScope with MANDATORY.


supports

public static TxScope supports()
Helper method to create a TxScope with SUPPORTS.


notSupported

public static TxScope notSupported()
Helper method to create a TxScope with NOT_SUPPORTED.


never

public static TxScope never()
Helper method to create a TxScope with NEVER.


toString

public String toString()
Describes this TxScope instance.

Overrides:
toString in class Object

getType

public TxType getType()
Return the transaction type.


setType

public TxScope setType(TxType type)
Set the transaction type.


isReadonly

public boolean isReadonly()
Return if the transaction should be treated as read only.


setReadOnly

public TxScope setReadOnly(boolean readOnly)
Set if the transaction should be treated as read only.


getIsolation

public TxIsolation getIsolation()
Return the Isolation level this transaction should run with.


setIsolation

public TxScope setIsolation(TxIsolation isolation)
Set the transaction isolation level this transaction should run with.


getServerName

public String getServerName()
Return the serverName for this transaction. If this is null then the default server (default DataSource) will be used.


setServerName

public TxScope setServerName(String serverName)
Set the serverName (DataSource name) for which this transaction will be. If the serverName is not specified (left null) then the default server will be used.


getRollbackFor

public ArrayList<Class<? extends Throwable>> getRollbackFor()
Return the throwable's that should cause a rollback.


setRollbackFor

public TxScope setRollbackFor(Class<? extends Throwable> rollbackThrowable)
Set a Throwable that should explicitly cause a rollback.


setRollbackFor

public TxScope setRollbackFor(Class<?>[] rollbackThrowables)
Set multiple throwable's that will cause a rollback.


getNoRollbackFor

public ArrayList<Class<? extends Throwable>> getNoRollbackFor()
Return the throwable's that should NOT cause a rollback.


setNoRollbackFor

public TxScope setNoRollbackFor(Class<? extends Throwable> noRollback)
Add a Throwable to a list that will NOT cause a rollback. You are able to call this method multiple times with different throwable's and they will added to a list.


setNoRollbackFor

public TxScope setNoRollbackFor(Class<?>[] noRollbacks)
Set multiple throwable's that will NOT cause a rollback.



Copyright © 2010. All Rights Reserved.