java.lang.Object
org.seasar.doma.jdbc.tx.LocalTransactionManager
- All Implemented Interfaces:
TransactionManager
A transaction manager for local transactions.
This instance is thread safe.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLocalTransactionManager(LocalTransaction transaction) Create an instance.LocalTransactionManager(LocalTransactionDataSource dataSource, JdbcLogger jdbcLogger) Create an instance.LocalTransactionManager(LocalTransactionDataSource dataSource, JdbcLogger jdbcLogger, TransactionIsolationLevel isolationLevel) Create an instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected <RESULT> RESULTexecuteInTransaction(TransactionIsolationLevel isolationLevel, Supplier<RESULT> supplier) Returns the transaction.booleanhasSavepoint(String savepointName) Whether the current transaction has the save point.booleanWhether the current transaction is marked to be undone.voidnotSupported(Runnable block) Executes the transaction whose attribute is NOT_SUPPORTED.<RESULT> RESULTnotSupported(Supplier<RESULT> supplier) Executes the transaction whose attribute is NOT_SUPPORTED and returns the result.voidnotSupported(TransactionIsolationLevel isolationLevel, Runnable block) Executes the transaction whose attribute is NOT_SUPPORTED with the specified transaction isolation level.<RESULT> RESULTnotSupported(TransactionIsolationLevel isolationLevel, Supplier<RESULT> supplier) Executes the transaction whose attribute is NOT_SUPPORTED with the specified transaction isolation level and return the result.protected <RESULT> RESULTnotSupportedInternal(TransactionIsolationLevel isolationLevel, Supplier<RESULT> supplier) voidreleaseSavepoint(String savepointName) Removes the specified save point and subsequent save points from the current transaction.voidExecutes the transaction whose attribute is REQUIRED.<RESULT> RESULTExecutes the transaction whose attribute is REQUIRED and returns the result.voidrequired(TransactionIsolationLevel isolationLevel, Runnable block) Executes the transaction whose attribute is REQUIRED with the specified transaction isolation level.<RESULT> RESULTrequired(TransactionIsolationLevel isolationLevel, Supplier<RESULT> supplier) Executes the transaction whose attribute is REQUIRED with the specified transaction isolation level and return the result.protected <RESULT> RESULTrequiredInternal(TransactionIsolationLevel isolationLevel, Supplier<RESULT> supplier) voidrequiresNew(Runnable block) Executes the transaction whose attribute is REQUIRES_NEW.<RESULT> RESULTrequiresNew(Supplier<RESULT> supplier) Executes the transaction whose attribute is REQUIRES_NEW and returns the result.voidrequiresNew(TransactionIsolationLevel isolationLevel, Runnable block) Executes the transaction whose attribute is REQUIRES_NEW with the specified transaction isolation level.<RESULT> RESULTrequiresNew(TransactionIsolationLevel isolationLevel, Supplier<RESULT> supplier) Executes the transaction whose attribute is REQUIRES_NEW with the specified transaction isolation level and return the result.protected <RESULT> RESULTrequiresNewInternal(TransactionIsolationLevel isolationLevel, Supplier<RESULT> supplier) voidUndoes all changes made after the given save point.voidMarks the current transaction to undo in the end of the transaction.voidsetSavepoint(String savepointName) Creates a save point with the specified name.toSupplier(Runnable block)
-
Field Details
-
transaction
-
-
Constructor Details
-
LocalTransactionManager
Create an instance.- Parameters:
transaction- the transaction- Throws:
DomaNullPointerException- if thetransactionisnull
-
LocalTransactionManager
Create an instance.- Parameters:
dataSource- the data sourcejdbcLogger- the logger- Throws:
DomaNullPointerException- if any of the parameters arenull
-
LocalTransactionManager
public LocalTransactionManager(LocalTransactionDataSource dataSource, JdbcLogger jdbcLogger, TransactionIsolationLevel isolationLevel) Create an instance.- Parameters:
dataSource- the data sourcejdbcLogger- the loggerisolationLevel- the default transaction isolation level- Throws:
DomaNullPointerException- if any of the parameters arenull
-
-
Method Details
-
getTransaction
Returns the transaction.This method is mainly used in test code.
- Returns:
- the transaction
-
required
Description copied from interface:TransactionManagerExecutes the transaction whose attribute is REQUIRED.- Specified by:
requiredin interfaceTransactionManager- Parameters:
block- the code that is executed in the transaction
-
required
Description copied from interface:TransactionManagerExecutes the transaction whose attribute is REQUIRED with the specified transaction isolation level.- Specified by:
requiredin interfaceTransactionManager- Parameters:
isolationLevel- the transaction isolation levelblock- the code that is executed in the transaction
-
required
Description copied from interface:TransactionManagerExecutes the transaction whose attribute is REQUIRED and returns the result.- Specified by:
requiredin interfaceTransactionManager- Type Parameters:
RESULT- the result type- Parameters:
supplier- the code that is executed in the transaction- Returns:
- the result
-
required
public <RESULT> RESULT required(TransactionIsolationLevel isolationLevel, Supplier<RESULT> supplier) Description copied from interface:TransactionManagerExecutes the transaction whose attribute is REQUIRED with the specified transaction isolation level and return the result.- Specified by:
requiredin interfaceTransactionManager- Type Parameters:
RESULT- the result type- Parameters:
isolationLevel- the transaction isolation levelsupplier- the code that is executed in the transaction- Returns:
- the result
-
requiredInternal
protected <RESULT> RESULT requiredInternal(TransactionIsolationLevel isolationLevel, Supplier<RESULT> supplier) -
requiresNew
Description copied from interface:TransactionManagerExecutes the transaction whose attribute is REQUIRES_NEW.- Specified by:
requiresNewin interfaceTransactionManager- Parameters:
block- the code that is executed in the transaction
-
requiresNew
Description copied from interface:TransactionManagerExecutes the transaction whose attribute is REQUIRES_NEW with the specified transaction isolation level.- Specified by:
requiresNewin interfaceTransactionManager- Parameters:
isolationLevel- the transaction isolation levelblock- the code that is executed in the transaction
-
requiresNew
Description copied from interface:TransactionManagerExecutes the transaction whose attribute is REQUIRES_NEW and returns the result.- Specified by:
requiresNewin interfaceTransactionManager- Type Parameters:
RESULT- the result type- Parameters:
supplier- the code that is executed in the transaction- Returns:
- the result
-
requiresNew
public <RESULT> RESULT requiresNew(TransactionIsolationLevel isolationLevel, Supplier<RESULT> supplier) Description copied from interface:TransactionManagerExecutes the transaction whose attribute is REQUIRES_NEW with the specified transaction isolation level and return the result.- Specified by:
requiresNewin interfaceTransactionManager- Type Parameters:
RESULT- the result type- Parameters:
isolationLevel- the transaction isolation levelsupplier- the code that is executed in the transaction- Returns:
- the result
-
requiresNewInternal
protected <RESULT> RESULT requiresNewInternal(TransactionIsolationLevel isolationLevel, Supplier<RESULT> supplier) -
notSupported
Description copied from interface:TransactionManagerExecutes the transaction whose attribute is NOT_SUPPORTED.- Specified by:
notSupportedin interfaceTransactionManager- Parameters:
block- the code that is executed in the transaction
-
notSupported
Description copied from interface:TransactionManagerExecutes the transaction whose attribute is NOT_SUPPORTED with the specified transaction isolation level.- Specified by:
notSupportedin interfaceTransactionManager- Parameters:
isolationLevel- the transaction isolation levelblock- the code that is executed in the transaction
-
notSupported
Description copied from interface:TransactionManagerExecutes the transaction whose attribute is NOT_SUPPORTED and returns the result.- Specified by:
notSupportedin interfaceTransactionManager- Type Parameters:
RESULT- the result type- Parameters:
supplier- the code that is executed in the transaction- Returns:
- the result
-
notSupported
public <RESULT> RESULT notSupported(TransactionIsolationLevel isolationLevel, Supplier<RESULT> supplier) Description copied from interface:TransactionManagerExecutes the transaction whose attribute is NOT_SUPPORTED with the specified transaction isolation level and return the result.- Specified by:
notSupportedin interfaceTransactionManager- Type Parameters:
RESULT- the result type- Parameters:
isolationLevel- the transaction isolation levelsupplier- the code that is executed in the transaction- Returns:
- the result
-
notSupportedInternal
protected <RESULT> RESULT notSupportedInternal(TransactionIsolationLevel isolationLevel, Supplier<RESULT> supplier) -
toSupplier
-
setRollbackOnly
public void setRollbackOnly()Description copied from interface:TransactionManagerMarks the current transaction to undo in the end of the transaction.- Specified by:
setRollbackOnlyin interfaceTransactionManager
-
isRollbackOnly
public boolean isRollbackOnly()Description copied from interface:TransactionManagerWhether the current transaction is marked to be undone.- Specified by:
isRollbackOnlyin interfaceTransactionManager- Returns:
trueif the current transaction is marked.
-
executeInTransaction
protected <RESULT> RESULT executeInTransaction(TransactionIsolationLevel isolationLevel, Supplier<RESULT> supplier) -
setSavepoint
Description copied from interface:TransactionManagerCreates a save point with the specified name.Begin a transaction before invoking this method.
- Specified by:
setSavepointin interfaceTransactionManager- Parameters:
savepointName- the name of the save point
-
hasSavepoint
Description copied from interface:TransactionManagerWhether the current transaction has the save point.Begin a transaction before invoking this method.
- Specified by:
hasSavepointin interfaceTransactionManager- Parameters:
savepointName- the name of the save point- Returns:
trueif the transaction has the save point
-
releaseSavepoint
Description copied from interface:TransactionManagerRemoves the specified save point and subsequent save points from the current transaction.Begin a transaction before invoking this method.
- Specified by:
releaseSavepointin interfaceTransactionManager- Parameters:
savepointName- the name of the save point
-
rollback
Description copied from interface:TransactionManagerUndoes all changes made after the given save point.Begin a transaction before invoking this method.
- Specified by:
rollbackin interfaceTransactionManager- Parameters:
savepointName- the name of the save point
-