diff --git a/jOOQ/src/main/java/org/jooq/TransactionContext.java b/jOOQ/src/main/java/org/jooq/TransactionContext.java
index 667c874dc2..1062b2f3f5 100644
--- a/jOOQ/src/main/java/org/jooq/TransactionContext.java
+++ b/jOOQ/src/main/java/org/jooq/TransactionContext.java
@@ -60,13 +60,28 @@ public interface TransactionContext extends Scope {
/**
* The exception that has caused the rollback.
*
- * @return The exception. May be null.
+ * @return The exception. May be null, in particular if the
+ * cause is a {@link Throwable}, in case of which
+ * {@link #causeThrowable()} should be called.
*/
Exception cause();
+ /**
+ * The throwable that has caused the rollback.
+ *
+ * @return The throwable. May be null.
+ */
+ Throwable causeThrowable();
+
/**
* Set the exception that has caused the rollback to the current transaction
* context.
*/
TransactionContext cause(Exception cause);
+
+ /**
+ * Set the throwable that has caused the rollback to the current transaction
+ * context.
+ */
+ TransactionContext causeThrowable(Throwable cause);
}
diff --git a/jOOQ/src/main/java/org/jooq/impl/DefaultTransactionContext.java b/jOOQ/src/main/java/org/jooq/impl/DefaultTransactionContext.java
index 10cd2882f5..ff10e77bfd 100644
--- a/jOOQ/src/main/java/org/jooq/impl/DefaultTransactionContext.java
+++ b/jOOQ/src/main/java/org/jooq/impl/DefaultTransactionContext.java
@@ -44,7 +44,7 @@ import org.jooq.TransactionContext;
class DefaultTransactionContext extends AbstractScope implements TransactionContext {
Transaction transaction;
- Exception cause;
+ Throwable cause;
DefaultTransactionContext(Configuration configuration) {
super(configuration);
@@ -63,7 +63,7 @@ class DefaultTransactionContext extends AbstractScope implements TransactionCont
@Override
public final Exception cause() {
- return cause;
+ return cause instanceof Exception ? (Exception) cause : null;
}
@Override
@@ -71,4 +71,15 @@ class DefaultTransactionContext extends AbstractScope implements TransactionCont
cause = c;
return this;
}
+
+ @Override
+ public final Throwable causeThrowable() {
+ return cause;
+ }
+
+ @Override
+ public final TransactionContext causeThrowable(Throwable c) {
+ cause = c;
+ return this;
+ }
}