Exemplo n.º 1
0
  public <ReturnType> ReturnType inTransaction(
      TransactionIsolationLevel level, TransactionCallback<ReturnType> callback) {
    final TransactionIsolationLevel initial = getTransactionIsolationLevel();
    boolean failed = true;
    try {
      setTransactionIsolation(level);

      ReturnType result = transactions.inTransaction(this, level, callback);
      failed = false;

      return result;
    } finally {
      try {
        setTransactionIsolation(initial);
      } catch (RuntimeException e) {
        if (!failed) {
          throw e;
        }

        // Ignore, there was already an exceptional condition and we don't want to clobber it.
      }
    }
  }
Exemplo n.º 2
0
 public <ReturnType> ReturnType inTransaction(TransactionCallback<ReturnType> callback) {
   return transactions.inTransaction(this, callback);
 }
Exemplo n.º 3
0
 /**
  * Rollback a transaction to a named checkpoint
  *
  * @param checkpointName the name of the checkpoint, previously declared with {@see
  *     Handle#checkpoint}
  */
 public Handle rollback(String checkpointName) {
   final long start = System.nanoTime();
   transactions.rollback(this, checkpointName);
   log.logRollbackToCheckpoint((System.nanoTime() - start) / 1000000L, this, checkpointName);
   return this;
 }
Exemplo n.º 4
0
 public boolean isInTransaction() {
   return transactions.isInTransaction(this);
 }
Exemplo n.º 5
0
 /**
  * Release the named checkpoint, making rollback to it not possible.
  *
  * @return The same handle
  */
 public Handle release(String checkpointName) {
   transactions.release(this, checkpointName);
   log.logReleaseCheckpointTransaction(this, checkpointName);
   return this;
 }
Exemplo n.º 6
0
 /**
  * Create a transaction checkpoint (savepoint in JDBC terminology) with the name provided.
  *
  * @param name The name of the checkpoint
  * @return The same handle
  */
 public Handle checkpoint(String name) {
   transactions.checkpoint(this, name);
   log.logCheckpointTransaction(this, name);
   return this;
 }
Exemplo n.º 7
0
 /** Rollback a transaction */
 public Handle rollback() {
   final long start = System.nanoTime();
   transactions.rollback(this);
   log.logRollbackTransaction((System.nanoTime() - start) / 1000000L, this);
   return this;
 }
Exemplo n.º 8
0
 /** Commit a transaction */
 public Handle commit() {
   final long start = System.nanoTime();
   transactions.commit(this);
   log.logCommitTransaction((System.nanoTime() - start) / 1000000L, this);
   return this;
 }
Exemplo n.º 9
0
 /** Start a transaction */
 public Handle begin() {
   transactions.begin(this);
   log.logBeginTransaction(this);
   return this;
 }