Package io.ebean
Class TxScope
- java.lang.Object
-
- io.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 Runnable or Callable via
DB.execute(TxScope, Runnable)orDB.executeCall(TxScope, Callable).This object is used internally with the enhancement of a method with Transactional annotation.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckBatchMode()Check for batchSize being set without batch mode and use this to imply PersistBatch.ALL.io.ebean.annotation.PersistBatchgetBatch()Return the batch mode.io.ebean.annotation.PersistBatchgetBatchOnCascade()Return the batch on cascade mode.intgetBatchSize()Return the batch size.io.ebean.annotation.TxIsolationgetIsolation()Return the Isolation level this transaction should run with.intgetIsolationLevel()Return the isolation level.StringgetLabel()Return the label for the transaction.ArrayList<Class<? extends Throwable>>getNoRollbackFor()Return the throwable's that should NOT cause a rollback.intgetProfileId()Return the transaction profile id.ProfileLocationgetProfileLocation()Return the profile location.ArrayList<Class<? extends Throwable>>getRollbackFor()Return the throwable's that should cause a rollback.StringgetServerName()Return the serverName for this transaction.io.ebean.annotation.TxTypegetType()Return the transaction type.booleanisBatchMode()booleanisBatchOnCascade()booleanisBatchOnCascadeSet()Return true if batch on cascade has been set.booleanisBatchSet()Return true if PersistBatch has been set.booleanisBatchSizeSet()Return true if batch size has been set.booleanisFlushOnQuery()Return false if the JDBC batch buffer should not be flushed automatically when a query is executed.booleanisReadonly()Return if the transaction should be treated as read only.booleanisSkipCache()Return true if the L2 cache should be skipped for this transaction.booleanisSkipGeneratedKeys()Return true if getGeneratedKeys should be skipped for this transaction.static TxScopemandatory()Helper method to create a TxScope with MANDATORY.static TxScopenever()Helper method to create a TxScope with NEVER.static TxScopenotSupported()Helper method to create a TxScope with NOT_SUPPORTED.static TxScoperequired()Helper method to create a TxScope with REQUIRES.static TxScoperequiresNew()Helper method to create a TxScope with REQUIRES_NEW.TxScopesetBatch(io.ebean.annotation.PersistBatch batch)Set the batch mode to use.TxScopesetBatchOnCascade(io.ebean.annotation.PersistBatch batchOnCascade)Set the batch on cascade mode.TxScopesetBatchSize(int batchSize)Set the batch size to use.TxScopesetFlushOnQuery(boolean flushOnQuery)Set flushOnQuery to be false to stop automatically flushing the JDBC batch buffer when a query is executed.TxScopesetIsolation(io.ebean.annotation.TxIsolation isolation)Set the transaction isolation level this transaction should run with.TxScopesetLabel(String label)Set a label for the transaction.TxScopesetNoRollbackFor(Class<?>[] noRollbacks)Set multiple throwable's that will NOT cause a rollback.TxScopesetNoRollbackFor(Class<? extends Throwable> noRollback)Add a Throwable to a list that will NOT cause a rollback.TxScopesetProfileId(int profileId)Set the transaction profile id.TxScopesetProfileLocation(ProfileLocation profileLocation)Set the profile location.TxScopesetReadOnly(boolean readOnly)Set if the transaction should be treated as read only.TxScopesetRollbackFor(Class<?>[] rollbackThrowables)Set multiple throwable's that will cause a rollback.TxScopesetRollbackFor(Class<? extends Throwable> rollbackThrowable)Set a Throwable that should explicitly cause a rollback.TxScopesetServerName(String serverName)Set the serverName (DataSource name) for which this transaction will be.TxScopesetSkipCache(boolean skipCache)Set to true if the transaction should skip L2 cache access.TxScopesetSkipGeneratedKeys()Set if the transaction should skip reading generated keys for inserts.TxScopesetType(io.ebean.annotation.TxType type)Set the transaction type.static TxScopesupports()Helper method to create a TxScope with SUPPORTS.StringtoString()Describes this TxScope instance.
-
-
-
Method Detail
-
requiresNew
public static TxScope requiresNew()
Helper method to create a TxScope with REQUIRES_NEW.
-
notSupported
public static TxScope notSupported()
Helper method to create a TxScope with NOT_SUPPORTED.
-
isBatchSet
public boolean isBatchSet()
Return true if PersistBatch has been set.
-
isBatchOnCascadeSet
public boolean isBatchOnCascadeSet()
Return true if batch on cascade has been set.
-
isBatchSizeSet
public boolean isBatchSizeSet()
Return true if batch size has been set.
-
checkBatchMode
public void checkBatchMode()
Check for batchSize being set without batch mode and use this to imply PersistBatch.ALL.
-
getType
public io.ebean.annotation.TxType getType()
Return the transaction type.
-
getProfileId
public int getProfileId()
Return the transaction profile id.
-
setProfileId
public TxScope setProfileId(int profileId)
Set the transaction profile id.
-
getProfileLocation
public ProfileLocation getProfileLocation()
Return the profile location.
-
setProfileLocation
public TxScope setProfileLocation(ProfileLocation profileLocation)
Set the profile location.
-
isSkipCache
public boolean isSkipCache()
Return true if the L2 cache should be skipped for this transaction.
-
setSkipCache
public TxScope setSkipCache(boolean skipCache)
Set to true if the transaction should skip L2 cache access.
-
getBatch
public io.ebean.annotation.PersistBatch getBatch()
Return the batch mode.
-
setBatch
public TxScope setBatch(io.ebean.annotation.PersistBatch batch)
Set the batch mode to use.
-
getBatchOnCascade
public io.ebean.annotation.PersistBatch getBatchOnCascade()
Return the batch on cascade mode.
-
setBatchOnCascade
public TxScope setBatchOnCascade(io.ebean.annotation.PersistBatch batchOnCascade)
Set the batch on cascade mode.
-
getBatchSize
public int getBatchSize()
Return the batch size. 0 means use the default value.
-
setBatchSize
public TxScope setBatchSize(int batchSize)
Set the batch size to use.
-
setSkipGeneratedKeys
public TxScope setSkipGeneratedKeys()
Set if the transaction should skip reading generated keys for inserts.
-
isSkipGeneratedKeys
public boolean isSkipGeneratedKeys()
Return true if getGeneratedKeys should be skipped for this transaction.
-
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.
-
isFlushOnQuery
public boolean isFlushOnQuery()
Return false if the JDBC batch buffer should not be flushed automatically when a query is executed.
-
setFlushOnQuery
public TxScope setFlushOnQuery(boolean flushOnQuery)
Set flushOnQuery to be false to stop automatically flushing the JDBC batch buffer when a query is executed.
-
getIsolationLevel
public int getIsolationLevel()
Return the isolation level.
-
getIsolation
public io.ebean.annotation.TxIsolation getIsolation()
Return the Isolation level this transaction should run with.
-
setIsolation
public TxScope setIsolation(io.ebean.annotation.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.
-
isBatchMode
public boolean isBatchMode()
-
isBatchOnCascade
public boolean isBatchOnCascade()
-
-