mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-12 14:40:46 +00:00
Yeah, nah. This is the real fix. Expose: SpiTransaction TransctionManager.getInScope(); ... and have ebean-spring-txn SpringJdbcTransactionManager call it instead of getActive().
This commit is contained in:
1 parent
73b2cc55f3
commit
175714046a
6 files changed
+29
-23
No files matched your search
+2
-2
@@ -28,12 +28,12 @@ public class DefaultTransactionScopeManager extends TransactionScopeManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpiTransaction getMaybeInactive() {
|
||||
public SpiTransaction getInScope() {
|
||||
return DefaultTransactionThreadLocal.get(serverName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpiTransaction get() {
|
||||
public SpiTransaction getActive() {
|
||||
SpiTransaction t = DefaultTransactionThreadLocal.get(serverName);
|
||||
if (t == null || !t.isActive()) {
|
||||
return null;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.ebeaninternal.server.transaction;
|
||||
|
||||
import io.ebean.config.ExternalTransactionManager;
|
||||
import io.ebeaninternal.api.SpiTransaction;
|
||||
|
||||
/**
|
||||
* A TransactionScopeManager aware of external transaction managers.
|
||||
@@ -22,4 +23,9 @@ public class ExternalTransactionScopeManager extends DefaultTransactionScopeMana
|
||||
externalManager.setTransactionManager(manager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpiTransaction getActive() {
|
||||
return (SpiTransaction) externalManager.getCurrentTransaction();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -201,22 +201,22 @@ public class TransactionManager implements SpiTransactionManager {
|
||||
/**
|
||||
* Return the current active transaction.
|
||||
*/
|
||||
public SpiTransaction get() {
|
||||
return scopeManager.get();
|
||||
public SpiTransaction getActive() {
|
||||
return scopeManager.getActive();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current active transaction as a scoped transaction.
|
||||
*/
|
||||
public ScopedTransaction getScoped() {
|
||||
return (ScopedTransaction) scopeManager.get();
|
||||
public ScopedTransaction getActiveScoped() {
|
||||
return (ScopedTransaction) scopeManager.getActive();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current scoped transaction allowing it to be inactive (already committed or rolled back).
|
||||
* Return the current transaction from thread local scope. Note that it may be inactive.
|
||||
*/
|
||||
private ScopedTransaction getMaybeInactive() {
|
||||
return (ScopedTransaction)scopeManager.getMaybeInactive();
|
||||
public SpiTransaction getInScope() {
|
||||
return scopeManager.getInScope();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -420,7 +420,7 @@ public class TransactionManager implements SpiTransactionManager {
|
||||
}
|
||||
|
||||
public void externalModification(TransactionEventTable tableEvent) {
|
||||
SpiTransaction t = get();
|
||||
SpiTransaction t = getActive();
|
||||
if (t != null) {
|
||||
t.getEvent().add(tableEvent);
|
||||
} else {
|
||||
@@ -555,11 +555,11 @@ public class TransactionManager implements SpiTransactionManager {
|
||||
* Exit a scoped transaction (that can be inactive - already committed etc).
|
||||
*/
|
||||
public void exitScopedTransaction(Object returnOrThrowable, int opCode) {
|
||||
ScopedTransaction st = getMaybeInactive();
|
||||
if (st != null) {
|
||||
SpiTransaction st = getInScope();
|
||||
if (st instanceof ScopedTransaction) {
|
||||
// can be null for Supports as that can start as a 'No Transaction' and then
|
||||
// effectively be replaced by transactions inside the scope
|
||||
st.complete(returnOrThrowable, opCode);
|
||||
((ScopedTransaction)st).complete(returnOrThrowable, opCode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -588,7 +588,7 @@ public class TransactionManager implements SpiTransactionManager {
|
||||
txScope = initTxScope(txScope);
|
||||
|
||||
boolean setToScope = false;
|
||||
ScopedTransaction txnContainer = getScoped();
|
||||
ScopedTransaction txnContainer = getActiveScoped();
|
||||
if (txnContainer == null) {
|
||||
setToScope = true;
|
||||
txnContainer = createScopedTransaction();
|
||||
|
||||
@@ -20,14 +20,14 @@ public abstract class TransactionScopeManager implements SpiTransactionScopeMana
|
||||
public abstract void register(TransactionManager manager);
|
||||
|
||||
/**
|
||||
* Return the current Transaction allowing it to be inactive.
|
||||
* Return the current Transaction from internal Ebean scope.
|
||||
*/
|
||||
public abstract SpiTransaction getMaybeInactive();
|
||||
public abstract SpiTransaction getInScope();
|
||||
|
||||
/**
|
||||
* Return the current Transaction for this serverName and Thread.
|
||||
* Return the current Transaction potentially looking in external scope (like Spring).
|
||||
*/
|
||||
public abstract SpiTransaction get();
|
||||
public abstract SpiTransaction getActive();
|
||||
|
||||
/**
|
||||
* Set a new Transaction for this serverName and Thread.
|
||||
|
||||
Reference in new issue
Block a user