diff options
Diffstat (limited to 'src/main/java/com/amazon/carbonado/txn')
-rw-r--r-- | src/main/java/com/amazon/carbonado/txn/TransactionManager.java | 10 | ||||
-rw-r--r-- | src/main/java/com/amazon/carbonado/txn/TransactionScope.java | 9 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/main/java/com/amazon/carbonado/txn/TransactionManager.java b/src/main/java/com/amazon/carbonado/txn/TransactionManager.java index 4914be9..528ade5 100644 --- a/src/main/java/com/amazon/carbonado/txn/TransactionManager.java +++ b/src/main/java/com/amazon/carbonado/txn/TransactionManager.java @@ -199,6 +199,16 @@ public abstract class TransactionManager<Txn> { }
/**
+ * Called when the Transaction.setForUpdate method is called. The default
+ * implementation of this method does nothing. Override if internal
+ * transaction needs to switch modes.
+ *
+ * @since 1.2.1
+ */
+ protected void setForUpdate(Txn txn, boolean forUpdate) {
+ }
+
+ /**
* Commits and closes the given internal transaction.
*
* @return true if transaction object is still valid
diff --git a/src/main/java/com/amazon/carbonado/txn/TransactionScope.java b/src/main/java/com/amazon/carbonado/txn/TransactionScope.java index 1e294e4..29c173c 100644 --- a/src/main/java/com/amazon/carbonado/txn/TransactionScope.java +++ b/src/main/java/com/amazon/carbonado/txn/TransactionScope.java @@ -408,7 +408,11 @@ public class TransactionScope<Txn> { }
public void setForUpdate(boolean forUpdate) {
- mForUpdate = forUpdate && mScope.mTxnMgr.supportsForUpdate();
+ mForUpdate = (forUpdate &= mScope.mTxnMgr.supportsForUpdate());
+ Txn txn = mTxn;
+ if (txn != null) {
+ mScope.mTxnMgr.setForUpdate(txn, forUpdate);
+ }
}
public boolean isForUpdate() {
@@ -472,6 +476,9 @@ public class TransactionScope<Txn> { mDesiredLockTimeout, mTimeoutUnit);
}
}
+ if (mForUpdate) {
+ scope.mTxnMgr.setForUpdate(mTxn, true);
+ }
return mTxn;
}
|