summaryrefslogtreecommitdiff
path: root/src/main/java/com/amazon/carbonado/repo/jdbc
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2007-10-23 18:09:08 +0000
committerBrian S. O'Neill <bronee@gmail.com>2007-10-23 18:09:08 +0000
commitf4b5012d20abe94c62e8d3b3c3d8ed626dff925b (patch)
tree7ed1c262d617a829dea07cef2964cb34e1f8e97d /src/main/java/com/amazon/carbonado/repo/jdbc
parent81578d7b6798fe5b268d1227cf33d24897d5bdaa (diff)
Deprecated use of ExceptionTransformer in TransactionManager.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/repo/jdbc')
-rw-r--r--src/main/java/com/amazon/carbonado/repo/jdbc/JDBCTransactionManager.java35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCTransactionManager.java b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCTransactionManager.java
index 7fa3fcc..862152d 100644
--- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCTransactionManager.java
+++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCTransactionManager.java
@@ -24,6 +24,7 @@ import java.sql.SQLException;
import com.amazon.carbonado.FetchException;
import com.amazon.carbonado.IsolationLevel;
+import com.amazon.carbonado.PersistException;
import com.amazon.carbonado.Transaction;
import com.amazon.carbonado.spi.TransactionManager;
@@ -34,12 +35,14 @@ import com.amazon.carbonado.spi.TransactionManager;
* @author Brian S O'Neill
*/
class JDBCTransactionManager extends TransactionManager<JDBCTransaction> {
+ private final JDBCExceptionTransformer mExTransformer;
+
// Weakly reference repository because thread locals are not cleaned up
// very quickly.
private final WeakReference<JDBCRepository> mRepositoryRef;
JDBCTransactionManager(JDBCRepository repository) {
- super(repository.getExceptionTransformer());
+ mExTransformer = repository.getExceptionTransformer();
mRepositoryRef = new WeakReference<JDBCRepository>(repository);
}
@@ -75,20 +78,28 @@ class JDBCTransactionManager extends TransactionManager<JDBCTransaction> {
return new JDBCTransaction(repo.getConnectionForTxn(level));
}
- protected boolean commitTxn(JDBCTransaction txn) throws SQLException {
- txn.commit();
- return true;
+ protected boolean commitTxn(JDBCTransaction txn) throws PersistException {
+ try {
+ txn.commit();
+ return true;
+ } catch (Throwable e) {
+ throw mExTransformer.toPersistException(e);
+ }
}
- protected void abortTxn(JDBCTransaction txn) throws SQLException, FetchException {
- Connection con;
- if ((con = txn.abort()) != null) {
- JDBCRepository repo = mRepositoryRef.get();
- if (repo == null) {
- con.close();
- } else {
- repo.yieldConnection(con);
+ protected void abortTxn(JDBCTransaction txn) throws PersistException {
+ try {
+ Connection con;
+ if ((con = txn.abort()) != null) {
+ JDBCRepository repo = mRepositoryRef.get();
+ if (repo == null) {
+ con.close();
+ } else {
+ repo.yieldConnection(con);
+ }
}
+ } catch (Throwable e) {
+ throw mExTransformer.toPersistException(e);
}
}
}