Package org.hibernate

Examples of org.hibernate.TransactionException


      final JtaPlatform jtaPlatform = transactionCoordinator
          .getTransactionContext()
          .getTransactionEnvironment()
          .getJtaPlatform();
      if ( jtaPlatform == null ) {
        throw new TransactionException( "Unable to check transaction status" );
      }
      if ( jtaPlatform.retrieveTransactionManager() != null ) {
        return JtaStatusHelper.isActive( jtaPlatform.retrieveTransactionManager().getStatus() );
      }
      else {
        final UserTransaction ut = jtaPlatform.retrieveUserTransaction();
        return ut != null && JtaStatusHelper.isActive( ut );
      }
    }
    catch ( SystemException se ) {
      throw new TransactionException( "Unable to check transaction status", se );
    }
  }
View Full Code Here


          .getJtaPlatform()
          .getCurrentStatus();
      return JtaStatusHelper.isActive( status );
    }
    catch( SystemException se ) {
      throw new TransactionException( "Unable to check transaction status", se );
    }
  }
View Full Code Here

    if ( transactionTimeOutInstant < 0 ) {
      return -1;
    }
    final int secondsRemaining = (int) ((transactionTimeOutInstant - System.currentTimeMillis()) / 1000);
    if ( secondsRemaining <= 0 ) {
      throw new TransactionException( "transaction timeout expired" );
    }
    return secondsRemaining;
  }
View Full Code Here

  }

  @Override
  public void begin() throws HibernateException {
    if ( !valid ) {
      throw new TransactionException( "Transaction instance is no longer valid" );
    }
    if ( localStatus == LocalStatus.ACTIVE ) {
      throw new TransactionException( "nested transactions not supported" );
    }
    if ( localStatus != LocalStatus.NOT_ACTIVE ) {
      throw new TransactionException( "reuse of Transaction instances not supported" );
    }

    LOG.debug( "begin" );

    doBegin();
View Full Code Here

  }

  @Override
  public void commit() throws HibernateException {
    if ( localStatus != LocalStatus.ACTIVE ) {
      throw new TransactionException( "Transaction not successfully started" );
    }

    LOG.debug( "committing" );

    beforeTransactionCommit();

    try {
      doCommit();
      localStatus = LocalStatus.COMMITTED;
      afterTransactionCompletion( Status.STATUS_COMMITTED );
    }
    catch (Exception e) {
      localStatus = LocalStatus.FAILED_COMMIT;
      afterTransactionCompletion( Status.STATUS_UNKNOWN );
      throw new TransactionException( "commit failed", e );
    }
    finally {
      invalidate();
      afterAfterCompletion();
    }
View Full Code Here

  }

  @Override
  public void rollback() throws HibernateException {
    if ( localStatus != LocalStatus.ACTIVE && localStatus != LocalStatus.FAILED_COMMIT ) {
      throw new TransactionException( "Transaction not successfully started" );
    }

    LOG.debug( "rolling back" );

    beforeTransactionRollBack();

    if ( localStatus != LocalStatus.FAILED_COMMIT || allowFailedCommitToPhysicallyRollback() ) {
      try {
        doRollback();
        localStatus = LocalStatus.ROLLED_BACK;
        afterTransactionCompletion( Status.STATUS_ROLLEDBACK );
      }
      catch (Exception e) {
        afterTransactionCompletion( Status.STATUS_UNKNOWN );
        throw new TransactionException( "rollback failed", e );
      }
      finally {
        invalidate();
        afterAfterCompletion();
      }
View Full Code Here

  @Override
  protected void doBegin() {
    try {
      if ( managedConnection != null ) {
        throw new TransactionException( "Already have an associated managed connection" );
      }
      managedConnection = transactionCoordinator().getJdbcCoordinator().getLogicalConnection().getConnection();
      wasInitiallyAutoCommit = managedConnection.getAutoCommit();
      LOG.debugv( "initial autocommit status: {0}", wasInitiallyAutoCommit );
      if ( wasInitiallyAutoCommit ) {
        LOG.debug( "disabling autocommit" );
        managedConnection.setAutoCommit( false );
      }
    }
    catch( SQLException e ) {
      throw new TransactionException( "JDBC begin transaction failed: ", e );
    }

    isDriver = transactionCoordinator().takeOwnership();
  }
View Full Code Here

    try {
      managedConnection.commit();
      LOG.debug( "committed JDBC Connection" );
    }
    catch( SQLException e ) {
      throw new TransactionException( "unable to commit against JDBC connection", e );
    }
    finally {
      releaseManagedConnection();
    }
  }
View Full Code Here

    try {
      managedConnection.rollback();
      LOG.debug( "rolled JDBC Connection" );
    }
    catch( SQLException e ) {
      throw new TransactionException( "unable to rollback against JDBC connection", e );
    }
    finally {
      releaseManagedConnection();
    }
  }
View Full Code Here

  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 = userTransaction.getStatus() == Status.STATUS_NO_TRANSACTION;
      if ( newTransaction ) {
        userTransaction.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

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.