Examples of TransactionException


Examples of org.hibernate.TransactionException

          //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");
View Full Code Here

Examples of org.hibernate.TransactionException

        try {
          UserTransaction ut = ( UserTransaction ) context.lookup( utName );
          return ut != null && JTAHelper.isInProgress( ut.getStatus() );
        }
        catch ( NamingException ne ) {
          throw new TransactionException( "Unable to locate UserTransaction to check status", ne );
        }
      }
    }
    catch ( SystemException se ) {
      throw new TransactionException( "Unable to check transaction status", se );
    }
  }
View Full Code Here

Examples of org.hibernate.TransactionException

      return JTAHelper.isTransactionInProgress(
          transactionContext.getFactory().getTransactionManager().getTransaction()
      );
    }
    catch( SystemException se ) {
      throw new TransactionException( "Unable to check transaction status", se );
    }

  }
View Full Code Here

Examples of org.hibernate.TransactionException

    try {
      ut = (UserTransaction) context.lookup(utName);
    }
    catch (NamingException ne) {
      log.error("Could not find UserTransaction in JNDI", ne);
      throw new TransactionException("Could not find UserTransaction in JNDI: ", ne);
    }
    if (ut==null) {
      throw new AssertionFailure("A naming service lookup returned null");
    }
View Full Code Here

Examples of org.hibernate.TransactionException

  public void begin() throws HibernateException {
    if (begun) {
      return;
    }
    if (commitFailed) {
      throw new TransactionException("cannot re-start transaction after failed commit");
    }
   
    log.debug("begin");

    try {
      newTransaction = ut.getStatus() == Status.STATUS_NO_TRANSACTION;
      if (newTransaction) {
        ut.begin();
        log.debug("Began a new JTA transaction");
      }
    }
    catch (Exception e) {
      log.error("JTA transaction begin failed", e);
      throw new TransactionException("JTA transaction begin failed", e);
    }

    /*if (newTransaction) {
      // don't need a synchronization since we are committing
      // or rolling back the transaction ourselves - assuming
View Full Code Here

Examples of org.hibernate.TransactionException

  /**
   * {@inheritDoc}
   */
  public void commit() throws HibernateException {
    if (!begun) {
      throw new TransactionException("Transaction not successfully started");
    }

    log.debug("commit");

    boolean flush = !transactionContext.isFlushModeNever()
            && ( callback || !transactionContext.isFlushBeforeCompletionEnabled() );

    if (flush) {
      transactionContext.managedFlush(); //if an exception occurs during flush, user must call rollback()
    }

    if (callback && newTransaction) {
      jdbcContext.beforeTransactionCompletion(this);
    }

    closeIfRequired();

    if (newTransaction) {
      try {
        ut.commit();
        commitSucceeded = true;
        log.debug("Committed JTA UserTransaction");
      }
      catch (Exception e) {
        commitFailed = true; // so the transaction is already rolled back, by JTA spec
        log.error("JTA commit failed", e);
        throw new TransactionException("JTA commit failed: ", e);
      }
      finally {
        afterCommitRollback();
      }
    }
View Full Code Here

Examples of org.hibernate.TransactionException

  /**
   * {@inheritDoc}
   */
  public void rollback() throws HibernateException {
    if (!begun && !commitFailed) {
      throw new TransactionException("Transaction not successfully started");
    }

    log.debug("rollback");

    /*if (!synchronization && newTransaction && !commitFailed) {
      jdbcContext.beforeTransactionCompletion(this);
    }*/

    try {
      closeIfRequired();
    }
    catch (Exception e) {
      log.error("could not close session during rollback", e);
      //swallow it, and continue to roll back JTA transaction
    }

    try {
      if (newTransaction) {
        if (!commitFailed) {
          ut.rollback();
          log.debug("Rolled back JTA UserTransaction");
        }
      }
      else {
        ut.setRollbackOnly();
        log.debug("set JTA UserTransaction to rollback only");
      }
    }
    catch (Exception e) {
      log.error("JTA rollback failed", e);
      throw new TransactionException("JTA rollback failed", e);
    }
    finally {
      afterCommitRollback();
    }
  }
View Full Code Here

Examples of org.hibernate.TransactionException

      try {
        status = ut.getStatus();
      }
      catch (Exception e) {
        log.error("Could not determine transaction status after commit", e);
        throw new TransactionException("Could not determine transaction status after commit", e);
      }
      finally {
        /*if (status!=Status.STATUS_COMMITTED && status!=Status.STATUS_ROLLEDBACK) {
          log.warn("Transaction not complete - you should set hibernate.transaction.manager_lookup_class if cache is enabled");
          //throw exception??
View Full Code Here

Examples of org.hibernate.TransactionException

    try {
      status = ut.getStatus();
    }
    catch (SystemException se) {
      log.error("Could not determine transaction status", se);
      throw new TransactionException("Could not determine transaction status", se);
    }
    if (status==Status.STATUS_UNKNOWN) {
      throw new TransactionException("Could not determine transaction status");
    }
    else {
      return JTAHelper.isRollback(status);
    }
  }
View Full Code Here

Examples of org.hibernate.TransactionException

    try {
      status = ut.getStatus();
    }
    catch (SystemException se) {
      log.error("Could not determine transaction status", se);
      throw new TransactionException("Could not determine transaction status: ", se);
    }
    if (status==Status.STATUS_UNKNOWN) {
      throw new TransactionException("Could not determine transaction status");
    }
    else {
      return status==Status.STATUS_COMMITTED;
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.