mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-12 14:40:46 +00:00
#1245 - Refactor internals - Add to TransactionManager externalRemoveTransaction() and externalBeginTransaction()
These provide a better/tidier way for external transaction managers (like ebean-spring-txn) to begin and end externally managed transactions.
This commit is contained in:
1 parent
71f66005e7
commit
f9cd955f7a
7 files changed
+178
-3
No files matched your search
@@ -16,6 +16,7 @@ import io.ebeaninternal.api.ScopeTrans;
|
||||
import io.ebeaninternal.api.ScopedTransaction;
|
||||
import io.ebeaninternal.api.SpiProfileHandler;
|
||||
import io.ebeaninternal.api.SpiTransaction;
|
||||
import io.ebeaninternal.api.SpiTransactionManager;
|
||||
import io.ebeaninternal.api.TransactionEvent;
|
||||
import io.ebeaninternal.api.TransactionEventTable;
|
||||
import io.ebeaninternal.api.TransactionEventTable.TableIUD;
|
||||
@@ -46,7 +47,7 @@ import java.util.Set;
|
||||
* Keeps the Cache and Cluster in synch when transactions are committed.
|
||||
* </p>
|
||||
*/
|
||||
public class TransactionManager {
|
||||
public class TransactionManager implements SpiTransactionManager {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(TransactionManager.class);
|
||||
|
||||
@@ -558,6 +559,23 @@ public class TransactionManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void externalRemoveTransaction() {
|
||||
scopeManager.replace(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Push an externally created transaction into scope. This transaction is usually managed externally
|
||||
* (e.g. Spring managed transaction).
|
||||
*/
|
||||
@Override
|
||||
public ScopedTransaction externalBeginTransaction(SpiTransaction transaction, TxScope txScope) {
|
||||
ScopedTransaction scopedTxn = new ScopedTransaction(scopeManager);
|
||||
scopedTxn.push(new ScopeTrans(rollbackOnChecked, false, transaction, txScope));
|
||||
scopeManager.set(scopedTxn);
|
||||
return scopedTxn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Begin a scoped transaction.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user