diff options
Diffstat (limited to 'src/main/java/com/amazon/carbonado/repo/jdbc')
4 files changed, 18 insertions, 14 deletions
diff --git a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCBlob.java b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCBlob.java index 69a8f3d..c031a9e 100644 --- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCBlob.java +++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCBlob.java @@ -126,7 +126,7 @@ class JDBCBlob extends AbstractBlob implements JDBCLob { throw new FetchException("Blob value is null");
}
try {
- JDBCTransaction txn = mRepo.localTxnScope().getTxn();
+ JDBCTransaction txn = mRepo.localTransactionScope().getTxn();
if (txn != null) {
txn.register(this);
}
@@ -143,7 +143,7 @@ class JDBCBlob extends AbstractBlob implements JDBCLob { if ((mBlob = mLoader.load(mRepo)) == null) {
throw new PersistException("Blob value is null");
}
- JDBCTransaction txn = mRepo.localTxnScope().getTxn();
+ JDBCTransaction txn = mRepo.localTransactionScope().getTxn();
if (txn != null) {
txn.register(this);
}
diff --git a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCClob.java b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCClob.java index eedaf80..dc2ec0a 100644 --- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCClob.java +++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCClob.java @@ -126,7 +126,7 @@ class JDBCClob extends AbstractClob implements JDBCLob { throw new FetchException("Clob value is null");
}
try {
- JDBCTransaction txn = mRepo.localTxnScope().getTxn();
+ JDBCTransaction txn = mRepo.localTransactionScope().getTxn();
if (txn != null) {
txn.register(this);
}
@@ -143,7 +143,7 @@ class JDBCClob extends AbstractClob implements JDBCLob { if ((mClob = mLoader.load(mRepo)) == null) {
throw new PersistException("Clob value is null");
}
- JDBCTransaction txn = mRepo.localTxnScope().getTxn();
+ JDBCTransaction txn = mRepo.localTransactionScope().getTxn();
if (txn != null) {
txn.register(this);
}
diff --git a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepository.java b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepository.java index dd4e1ad..75fde77 100644 --- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepository.java +++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepository.java @@ -55,6 +55,7 @@ import com.amazon.carbonado.info.StorableProperty; import com.amazon.carbonado.sequence.SequenceCapability;
import com.amazon.carbonado.sequence.SequenceValueProducer;
import com.amazon.carbonado.spi.AbstractRepository;
+import com.amazon.carbonado.spi.TransactionManager;
import com.amazon.carbonado.spi.TransactionScope;
import com.amazon.carbonado.util.ThrowUnchecked;
@@ -194,6 +195,8 @@ public class JDBCRepository extends AbstractRepository<JDBCTransaction> private final JDBCSupportStrategy mSupportStrategy;
private JDBCExceptionTransformer mExceptionTransformer;
+ private final JDBCTransactionManager mTxnMgr;
+
// Mappings from IsolationLevel to best matching supported level.
final IsolationLevel mReadUncommittedLevel;
final IsolationLevel mReadCommittedLevel;
@@ -246,6 +249,8 @@ public class JDBCRepository extends AbstractRepository<JDBCTransaction> // Temporarily set to generic one, in case there's a problem during initialization.
mExceptionTransformer = new JDBCExceptionTransformer();
+ mTxnMgr = new JDBCTransactionManager(this);
+
getLog().info("Opening repository \"" + getName() + '"');
// Test connectivity and get some info on transaction isolation levels.
@@ -697,12 +702,11 @@ public class JDBCRepository extends AbstractRepository<JDBCTransaction> return mSupportStrategy.createSequenceValueProducer(name);
}
- protected JDBCTransactionManager createTransactionManager() {
- return new JDBCTransactionManager(this);
+ protected final TransactionManager<JDBCTransaction> transactionManager() {
+ return mTxnMgr;
}
- // Provides access to transaction scope from other classes.
- final TransactionScope<JDBCTransaction> localTxnScope() {
- return localTransactionScope();
+ protected final TransactionScope<JDBCTransaction> localTransactionScope() {
+ return mTxnMgr.localScope();
}
}
diff --git a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorage.java b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorage.java index e6fe277..942ebee 100644 --- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorage.java +++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorage.java @@ -213,7 +213,7 @@ class JDBCStorage<S extends Storable> extends StandardQueryFactory<S> if (jblob != null) {
try {
- JDBCTransaction txn = mRepository.localTxnScope().getTxn();
+ JDBCTransaction txn = mRepository.localTransactionScope().getTxn();
if (txn != null) {
txn.register(jblob);
}
@@ -235,7 +235,7 @@ class JDBCStorage<S extends Storable> extends StandardQueryFactory<S> if (jclob != null) {
try {
- JDBCTransaction txn = mRepository.localTxnScope().getTxn();
+ JDBCTransaction txn = mRepository.localTransactionScope().getTxn();
if (txn != null) {
txn.register(jclob);
}
@@ -606,7 +606,7 @@ class JDBCStorage<S extends Storable> extends StandardQueryFactory<S> }
public Cursor<S> fetch(FilterValues<S> values) throws FetchException {
- boolean forUpdate = mRepository.localTxnScope().isForUpdate();
+ boolean forUpdate = mRepository.localTransactionScope().isForUpdate();
Connection con = mRepository.getConnection();
try {
PreparedStatement ps = con.prepareStatement(prepareSelect(values, forUpdate));
@@ -674,7 +674,7 @@ class JDBCStorage<S extends Storable> extends StandardQueryFactory<S> throws IOException
{
indent(app, indentLevel);
- boolean forUpdate = mRepository.localTxnScope().isForUpdate();
+ boolean forUpdate = mRepository.localTransactionScope().isForUpdate();
app.append(prepareSelect(values, forUpdate));
app.append('\n');
return true;
@@ -684,7 +684,7 @@ class JDBCStorage<S extends Storable> extends StandardQueryFactory<S> throws IOException
{
try {
- boolean forUpdate = mRepository.localTxnScope().isForUpdate();
+ boolean forUpdate = mRepository.localTransactionScope().isForUpdate();
String statement = prepareSelect(values, forUpdate);
return mRepository.getSupportStrategy().printPlan(app, indentLevel, statement);
} catch (FetchException e) {
|