Package io.ebeaninternal.api
Class ScopedTransaction
- java.lang.Object
-
- io.ebeaninternal.api.SpiTransactionProxy
-
- io.ebeaninternal.api.ScopedTransaction
-
- All Implemented Interfaces:
Transaction
,SpiTransaction
,AutoCloseable
public class ScopedTransaction extends SpiTransactionProxy
Manage scoped (typically thread local) transactions. These can be nested and internally they are pushed and popped from a stack.
-
-
Field Summary
-
Fields inherited from interface io.ebean.Transaction
READ_COMMITTED, READ_UNCOMMITTED, REPEATABLE_READ, SERIALIZABLE
-
-
Constructor Summary
Constructors Constructor Description ScopedTransaction(TransactionScopeManager manager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Error
caughtError(Error e)
Rollback for Error.Exception
caughtThrowable(Exception e)
Maybe rollback based on TxScope rollback on settings.void
close()
Synonym for end() to support AutoClosable.void
commit()
Commit the transaction.void
complete()
Internal programmatic complete - finally block, try to commit.void
complete(Object returnOrThrowable, int opCode)
Exiting an enhanced transactional method.SpiTransaction
current()
Return the current transaction.void
end()
If the transaction is active then perform rollback.void
push(ScopeTrans scopeTrans)
Push the scope transaction.void
rollback()
Rollback the transaction.void
rollback(Throwable e)
Rollback the transaction specifying a throwable that caused the rollback to occur.void
setRollbackOnly()
Mark the transaction for rollback only.String
toString()
-
Methods inherited from class io.ebeaninternal.api.SpiTransactionProxy
addBeanChange, addModification, checkBatchEscalationOnCascade, checkBatchEscalationOnCollection, commitAndContinue, depth, depth, flush, flushBatch, flushBatchOnCascade, flushBatchOnCollection, flushBatchOnRollback, getBatchControl, getBatchGetGeneratedKeys, getBatchSize, getConnection, getDocStoreBatchSize, getDocStoreMode, getDocStoreTransaction, getEvent, getId, getInternalConnection, getLabel, getLogPrefix, getPersistenceContext, getProfileLocation, getStartNanoTime, getTenantId, getUserObject, isActive, isBatchMode, isBatchOnCascade, isBatchThisRequest, isExplicit, isFlushOnQuery, isLogSql, isLogSummary, isNestedUseSavepoint, isPersistCascade, isReadOnly, isRegisteredBean, isRegisteredDeleteBean, isRollbackOnly, isSaveAssocManyIntersection, isSkipCache, isSkipCacheExplicit, isUpdateAllLoadedProperties, logSql, logSummary, markNotQueryOnly, profileEvent, profileOffset, profileStream, putUserObject, register, registerDeferred, registerDeleteBean, sendChangeLog, setBatchControl, setBatchMode, setBatchOnCascade, setBatchSize, setDocStoreBatchSize, setDocStoreMode, setFlushOnMixed, setFlushOnQuery, setGetGeneratedKeys, setLabel, setNestedUseSavepoint, setPersistCascade, setPersistenceContext, setProfileLocation, setProfileStream, setReadOnly, setSkipCache, setTenantId, setUpdateAllLoadedProperties, translate, unregisterBeans
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.ebean.Transaction
isBatchFlushOnQuery, setBatchFlushOnMixed, setBatchFlushOnQuery, setBatchGetGeneratedKeys
-
-
-
-
Constructor Detail
-
ScopedTransaction
public ScopedTransaction(TransactionScopeManager manager)
-
-
Method Detail
-
push
public void push(ScopeTrans scopeTrans)
Push the scope transaction.
-
complete
public void complete(Object returnOrThrowable, int opCode)
Exiting an enhanced transactional method.
-
complete
public void complete()
Internal programmatic complete - finally block, try to commit.
-
end
public void end() throws javax.persistence.PersistenceException
Description copied from interface:Transaction
If the transaction is active then perform rollback. Otherwise do nothing.- Throws:
javax.persistence.PersistenceException
-
close
public void close()
Description copied from interface:Transaction
Synonym for end() to support AutoClosable.
-
commit
public void commit()
Description copied from interface:Transaction
Commit the transaction.This performs commit and completes the transaction closing underlying resources and marking the transaction as "In active".
Functions
- Flush the JDBC batch buffer
- Call commit on the underlying JDBC connection
- Trigger any registered TransactionCallbacks
- Perform post-commit processing updating L2 cache, ElasticSearch etc
- Close any underlying resources, closing the underlying JDBC connection
- Mark the transaction as "Inactive"
-
rollback
public void rollback() throws javax.persistence.PersistenceException
Description copied from interface:Transaction
Rollback the transaction.This performs rollback, closes underlying resources and marks the transaction as "In active".
Functions
- Call rollback on the underlying JDBC connection
- Trigger any registered TransactionCallbacks
- Close any underlying resources, closing the underlying JDBC connection
- Mark the transaction as "Inactive"
- Throws:
javax.persistence.PersistenceException
-
rollback
public void rollback(Throwable e) throws javax.persistence.PersistenceException
Description copied from interface:Transaction
Rollback the transaction specifying a throwable that caused the rollback to occur.If you are using transaction logging this will log the throwable in the transaction logs.
- Throws:
javax.persistence.PersistenceException
-
setRollbackOnly
public void setRollbackOnly()
Description copied from interface:Transaction
Mark the transaction for rollback only.
-
current
public SpiTransaction current()
Return the current transaction.
-
caughtError
public Error caughtError(Error e)
Rollback for Error.
-
caughtThrowable
public Exception caughtThrowable(Exception e)
Maybe rollback based on TxScope rollback on settings.
-
-