#1935 - ENH: Add DB.createTransaction()

This commit is contained in:
rob bygrave
2020-02-07 15:52:26 +13:00
parent 8b4eae2f91
commit 62b1da1be2
2 changed files with 13 additions and 1 deletions
+12
View File
@@ -176,6 +176,18 @@ public class DB {
return getDefault().beginTransaction();
}
/**
* Create a new transaction that is not held in TransactionThreadLocal.
* <p>
* You will want to do this if you want multiple Transactions in a single
* thread or generally use transactions outside of the TransactionThreadLocal
* management.
* </p>
*/
public static Transaction createTransaction() {
return getDefault().createTransaction();
}
/**
* Start a transaction additionally specifying the isolation level.
*
@@ -41,7 +41,7 @@ public class TestQueryUsingConnection extends BaseTestCase {
ResetBasicData.reset();
try (Transaction transaction = DB.getDefault().createTransaction()) {
try (Transaction transaction = DB.createTransaction()) {
Transaction current = Transaction.current();
assertThat(current).isNull();