public class LocalTransactionManager extends java.lang.Object implements TransactionManager
This instance is thread safe.
| Modifier and Type | Field and Description |
|---|---|
protected LocalTransaction |
transaction |
| Constructor and Description |
|---|
LocalTransactionManager(LocalTransaction transaction)
Create an instance.
|
LocalTransactionManager(LocalTransactionDataSource dataSource,
JdbcLogger jdbcLogger)
Create an instance.
|
LocalTransactionManager(LocalTransactionDataSource dataSource,
JdbcLogger jdbcLogger,
TransactionIsolationLevel isolationLevel)
Create an instance.
|
| Modifier and Type | Method and Description |
|---|---|
protected <RESULT> RESULT |
executeInTransaction(TransactionIsolationLevel isolationLevel,
java.util.function.Supplier<RESULT> supplier) |
LocalTransaction |
getTransaction()
Returns the transaction.
|
boolean |
hasSavepoint(java.lang.String savepointName)
Whether the current transaction has the save point.
|
boolean |
isRollbackOnly()
Whether the current transaction is marked to be undone.
|
void |
notSupported(java.lang.Runnable block)
Executes the transaction whose attribute is NOT_SUPPORTED.
|
<RESULT> RESULT |
notSupported(java.util.function.Supplier<RESULT> supplier)
Executes the transaction whose attribute is NOT_SUPPORTED and returns the result.
|
void |
notSupported(TransactionIsolationLevel isolationLevel,
java.lang.Runnable block)
Executes the transaction whose attribute is NOT_SUPPORTED with the specified transaction
isolation level.
|
<RESULT> RESULT |
notSupported(TransactionIsolationLevel isolationLevel,
java.util.function.Supplier<RESULT> supplier)
Executes the transaction whose attribute is NOT_SUPPORTED with the specified transaction
isolation level and return the result.
|
protected <RESULT> RESULT |
notSupportedInternal(TransactionIsolationLevel isolationLevel,
java.util.function.Supplier<RESULT> supplier) |
void |
releaseSavepoint(java.lang.String savepointName)
Removes the specified save point and subsequent save points from the current transaction.
|
void |
required(java.lang.Runnable block)
Executes the transaction whose attribute is REQUIRED.
|
<RESULT> RESULT |
required(java.util.function.Supplier<RESULT> supplier)
Executes the transaction whose attribute is REQUIRED and returns the result.
|
void |
required(TransactionIsolationLevel isolationLevel,
java.lang.Runnable block)
Executes the transaction whose attribute is REQUIRED with the specified transaction isolation
level.
|
<RESULT> RESULT |
required(TransactionIsolationLevel isolationLevel,
java.util.function.Supplier<RESULT> supplier)
Executes the transaction whose attribute is REQUIRED with the specified transaction isolation
level and return the result.
|
protected <RESULT> RESULT |
requiredInternal(TransactionIsolationLevel isolationLevel,
java.util.function.Supplier<RESULT> supplier) |
void |
requiresNew(java.lang.Runnable block)
Executes the transaction whose attribute is REQUIRES_NEW.
|
<RESULT> RESULT |
requiresNew(java.util.function.Supplier<RESULT> supplier)
Executes the transaction whose attribute is REQUIRES_NEW and returns the result.
|
void |
requiresNew(TransactionIsolationLevel isolationLevel,
java.lang.Runnable block)
Executes the transaction whose attribute is REQUIRES_NEW with the specified transaction
isolation level.
|
<RESULT> RESULT |
requiresNew(TransactionIsolationLevel isolationLevel,
java.util.function.Supplier<RESULT> supplier)
Executes the transaction whose attribute is REQUIRES_NEW with the specified transaction
isolation level and return the result.
|
protected <RESULT> RESULT |
requiresNewInternal(TransactionIsolationLevel isolationLevel,
java.util.function.Supplier<RESULT> supplier) |
void |
rollback(java.lang.String savepointName)
Undoes all changes made after the given save point.
|
void |
setRollbackOnly()
Marks the current transaction to undo in the end of the transaction.
|
void |
setSavepoint(java.lang.String savepointName)
Creates a save point with the specified name.
|
protected java.util.function.Supplier<java.lang.Void> |
toSupplier(java.lang.Runnable block) |
protected final LocalTransaction transaction
public LocalTransactionManager(LocalTransaction transaction)
transaction - the transactionDomaNullPointerException - if the transaction is nullpublic LocalTransactionManager(LocalTransactionDataSource dataSource, JdbcLogger jdbcLogger)
dataSource - the data sourcejdbcLogger - the loggerDomaNullPointerException - if any of the parameters are nullpublic LocalTransactionManager(LocalTransactionDataSource dataSource, JdbcLogger jdbcLogger, TransactionIsolationLevel isolationLevel)
dataSource - the data sourcejdbcLogger - the loggerisolationLevel - the default transaction isolation levelDomaNullPointerException - if any of the parameters are nullpublic LocalTransaction getTransaction()
This method is mainly used in test code.
public void required(java.lang.Runnable block)
TransactionManagerrequired in interface TransactionManagerblock - the code that is executed in the transactionpublic void required(TransactionIsolationLevel isolationLevel, java.lang.Runnable block)
TransactionManagerrequired in interface TransactionManagerisolationLevel - the transaction isolation levelblock - the code that is executed in the transactionpublic <RESULT> RESULT required(java.util.function.Supplier<RESULT> supplier)
TransactionManagerrequired in interface TransactionManagerRESULT - the result typesupplier - the code that is executed in the transactionpublic <RESULT> RESULT required(TransactionIsolationLevel isolationLevel, java.util.function.Supplier<RESULT> supplier)
TransactionManagerrequired in interface TransactionManagerRESULT - the result typeisolationLevel - the transaction isolation levelsupplier - the code that is executed in the transactionprotected <RESULT> RESULT requiredInternal(TransactionIsolationLevel isolationLevel, java.util.function.Supplier<RESULT> supplier)
public void requiresNew(java.lang.Runnable block)
TransactionManagerrequiresNew in interface TransactionManagerblock - the code that is executed in the transactionpublic void requiresNew(TransactionIsolationLevel isolationLevel, java.lang.Runnable block)
TransactionManagerrequiresNew in interface TransactionManagerisolationLevel - the transaction isolation levelblock - the code that is executed in the transactionpublic <RESULT> RESULT requiresNew(java.util.function.Supplier<RESULT> supplier)
TransactionManagerrequiresNew in interface TransactionManagerRESULT - the result typesupplier - the code that is executed in the transactionpublic <RESULT> RESULT requiresNew(TransactionIsolationLevel isolationLevel, java.util.function.Supplier<RESULT> supplier)
TransactionManagerrequiresNew in interface TransactionManagerRESULT - the result typeisolationLevel - the transaction isolation levelsupplier - the code that is executed in the transactionprotected <RESULT> RESULT requiresNewInternal(TransactionIsolationLevel isolationLevel, java.util.function.Supplier<RESULT> supplier)
public void notSupported(java.lang.Runnable block)
TransactionManagernotSupported in interface TransactionManagerblock - the code that is executed in the transactionpublic void notSupported(TransactionIsolationLevel isolationLevel, java.lang.Runnable block)
TransactionManagernotSupported in interface TransactionManagerisolationLevel - the transaction isolation levelblock - the code that is executed in the transactionpublic <RESULT> RESULT notSupported(java.util.function.Supplier<RESULT> supplier)
TransactionManagernotSupported in interface TransactionManagerRESULT - the result typesupplier - the code that is executed in the transactionpublic <RESULT> RESULT notSupported(TransactionIsolationLevel isolationLevel, java.util.function.Supplier<RESULT> supplier)
TransactionManagernotSupported in interface TransactionManagerRESULT - the result typeisolationLevel - the transaction isolation levelsupplier - the code that is executed in the transactionprotected <RESULT> RESULT notSupportedInternal(TransactionIsolationLevel isolationLevel, java.util.function.Supplier<RESULT> supplier)
protected java.util.function.Supplier<java.lang.Void> toSupplier(java.lang.Runnable block)
public void setRollbackOnly()
TransactionManagersetRollbackOnly in interface TransactionManagerpublic boolean isRollbackOnly()
TransactionManagerisRollbackOnly in interface TransactionManagertrue if the current transaction is marked.protected <RESULT> RESULT executeInTransaction(TransactionIsolationLevel isolationLevel, java.util.function.Supplier<RESULT> supplier)
public void setSavepoint(java.lang.String savepointName)
TransactionManagerBegin a transaction before invoking this method.
setSavepoint in interface TransactionManagersavepointName - the name of the save pointpublic boolean hasSavepoint(java.lang.String savepointName)
TransactionManagerBegin a transaction before invoking this method.
hasSavepoint in interface TransactionManagersavepointName - the name of the save pointtrue if the transaction has the save pointpublic void releaseSavepoint(java.lang.String savepointName)
TransactionManagerBegin a transaction before invoking this method.
releaseSavepoint in interface TransactionManagersavepointName - the name of the save pointpublic void rollback(java.lang.String savepointName)
TransactionManagerBegin a transaction before invoking this method.
rollback in interface TransactionManagersavepointName - the name of the save point