Package org.hibernate

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 {
        userTransaction.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


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

    log.debug( "rollback" );

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

    try {
      if ( newTransaction ) {
        if ( !commitFailed ) {
          userTransaction.rollback();
          log.debug( "Rolled back JTA UserTransaction" );
        }
      }
      else {
        userTransaction.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

      try {
        status = userTransaction.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 {
        jdbcContext.afterTransactionCompletion( status == Status.STATUS_COMMITTED, this );
      }
    }
View Full Code Here

    try {
      status = userTransaction.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

    try {
      status = userTransaction.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

    try {
      status = userTransaction.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_ACTIVE;
    }
  }
View Full Code Here

    else {
      try {
        getTransactionManager().getTransaction().registerSynchronization( sync );
      }
      catch ( Exception e ) {
        throw new TransactionException( "could not register synchronization", e );
      }
    }
  }
View Full Code Here

  public void setTimeout(int seconds) {
    try {
      userTransaction.setTransactionTimeout( seconds );
    }
    catch ( SystemException se ) {
      throw new TransactionException( "could not set transaction timeout", se );
    }
  }
View Full Code Here

      return status == JoinStatus.JOINED && isTransactionInProgress(
          transactionContext.getFactory().getTransactionManager().getTransaction()
      );
    }
    catch (SystemException se) {
      throw new TransactionException( "Unable to check transaction status", se );
    }
  }
View Full Code Here

    try {
      Transaction transaction = transactionContext.getFactory().getTransactionManager().getTransaction();
      return isTransactionInProgress(transaction);
    }
    catch (SystemException se) {
      throw new TransactionException( "Unable to check transaction status", se );
    }
  }
View Full Code Here

TOP

Related Classes of org.hibernate.TransactionException

Copyright © 2018 www.massapicom. 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.