Package fr.paris.lutece.util.sql
Class TransactionManager
- java.lang.Object
-
- fr.paris.lutece.util.sql.TransactionManager
-
public final class TransactionManager extends java.lang.ObjectClass to manage transactions
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidbeginTransaction(Plugin plugin)Begin a transaction for the current thread using the pool of a specific plugin with the default transaction isolation.static voidbeginTransaction(Plugin plugin, int nTransactionIsolation)Begin a transaction for the current thread using the pool of a specific pluginstatic voidcommitTransaction(Plugin plugin)Commit the transaction associated to the pool of a given plugin.static MultiPluginTransactiongetCurrentTransaction(Plugin plugin)Get the current transaction for the pool of a given plugin.static voidrollBack(Plugin plugin)Roll back a transaction associated to the pool of a given plugin.static voidrollBack(Plugin plugin, java.lang.Exception e)Roll back a transaction associated to the pool of a given plugin with an exception.static voidrollBackEveryTransaction()Roll back every transactions opened by the current thread.static voidrollBackEveryTransaction(java.lang.Throwable e)Roll back every transactions opened by the current thread.
-
-
-
Method Detail
-
beginTransaction
public static void beginTransaction(Plugin plugin)
Begin a transaction for the current thread using the pool of a specific plugin with the default transaction isolation. The default transaction isolation isConnection.TRANSACTION_READ_COMMITTED.
Note that only one transaction may be active at a time by pool for each thread.- Parameters:
plugin- The plugin to use the pool of, or null to use the default pool.
-
beginTransaction
public static void beginTransaction(Plugin plugin, int nTransactionIsolation)
Begin a transaction for the current thread using the pool of a specific plugin- Parameters:
plugin- The plugin to use the pool of, or null to use the default pool.nTransactionIsolation- The transaction isolation. ViewConnection.setTransactionIsolation(int)to view the different available transaction isolations.
-
getCurrentTransaction
public static MultiPluginTransaction getCurrentTransaction(Plugin plugin)
Get the current transaction for the pool of a given plugin.- Parameters:
plugin- The plugin to use the pool of, or null to use the default pool.- Returns:
- The transaction, or null if no transaction is currently running.
-
commitTransaction
public static void commitTransaction(Plugin plugin)
Commit the transaction associated to the pool of a given plugin.- Parameters:
plugin- The plugin associated to the pool to commit the transaction of, or null to use the default pool.
-
rollBack
public static void rollBack(Plugin plugin)
Roll back a transaction associated to the pool of a given plugin. Note that any plugin can roll a transaction back.- Parameters:
plugin- The plugin associated to the pool to roll back the transaction of, or null to use the default pool.
-
rollBack
public static void rollBack(Plugin plugin, java.lang.Exception e)
Roll back a transaction associated to the pool of a given plugin with an exception.- Parameters:
plugin- The plugin associated to the pool to roll back the transaction of, or null to use the default pool.e- The exception to associates with the roll back.
-
rollBackEveryTransaction
public static void rollBackEveryTransaction()
Roll back every transactions opened by the current thread. This method attempt to prevent connection leak.
-
rollBackEveryTransaction
public static void rollBackEveryTransaction(java.lang.Throwable e)
Roll back every transactions opened by the current thread. This method attempt to prevent connection leak.- Parameters:
e- The exception that occurs and that may have prevent transaction from being properly closed (committed or roll backed)
-
-