public void beforeCompletion() {
    log.trace("transaction before completion callback");

    boolean flush;
    try {
      flush =
          !ctx.isFlushModeNever()
              && ctx.isFlushBeforeCompletionEnabled()
              && !JTAHelper.isRollback(transaction.getStatus());
      // actually, this last test is probably unnecessary, since
      // beforeCompletion() doesn't get called during rollback
    } catch (SystemException se) {
      log.error("could not determine transaction status", se);
      setRollbackOnly();
      throw new TransactionException(
          "could not determine transaction status in beforeCompletion()", se);
    }

    try {
      if (flush) {
        log.trace("automatically flushing session");
        ctx.managedFlush();
      }
    } catch (RuntimeException re) {
      setRollbackOnly();
      throw re;
    } finally {
      jdbcContext.beforeTransactionCompletion(hibernateTransaction);
    }
  }
 public boolean isTransactionInProgress(
     JDBCContext jdbcContext, Context transactionContext, Transaction transaction) {
   try {
     return JTAHelper.isTransactionInProgress(
         transactionContext.getFactory().getTransactionManager().getTransaction());
   } catch (SystemException se) {
     throw new TransactionException("Unable to check transaction status", se);
   }
 }