#791 - ENH: Add transaction.setRollbackOnly() ... (and Ebean.setRollbackOnly())

This commit is contained in:
Robin Bygrave committed 2016-07-31 21:24:31 +12:00
1 parent d82148248c
commit b4a1d52067
6 files changed
+93

No files matched your search

@@ -66,6 +66,8 @@ public class JdbcTransaction implements SpiTransaction {
*/
protected boolean active;
protected boolean rollbackOnly;
/**
* The underlying Connection.
*/
@@ -903,6 +905,10 @@ public class JdbcTransaction implements SpiTransaction {
*/
@Override
public void commit() throws RollbackException {
if (rollbackOnly) {
rollback();
return;
}
if (!isActive()) {
throw new IllegalStateException(illegalStateMessage);
}
@@ -945,6 +951,14 @@ public class JdbcTransaction implements SpiTransaction {
}
}
/**
* Mark the transaction as rollback only.
*/
@Override
public void setRollbackOnly() {
this.rollbackOnly = true;
}
/**
* Rollback the transaction.
*/