Package org.hibernate

Examples of org.hibernate.TransactionException


    log.trace( "Attempting to locate UserTransaction via JNDI [{}]", getUserTransactionName() );

    try {
      UserTransaction ut = ( UserTransaction ) getInitialContext().lookup( getUserTransactionName() );
      if ( ut == null ) {
        throw new TransactionException( "Naming service lookup for UserTransaction returned null [" + getUserTransactionName() +"]" );
      }

      log.trace( "Obtained UserTransaction" );

      return ut;
    }
    catch ( NamingException ne ) {
      throw new TransactionException( "Could not find UserTransaction in JNDI [" + getUserTransaction() + "]", ne );
    }
  }
View Full Code Here


        UserTransaction ut = getUserTransaction();
        return ut != null && JTAHelper.isInProgress( ut.getStatus() );
      }
    }
    catch ( SystemException se ) {
      throw new TransactionException( "Unable to check transaction status", se );
    }
  }
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 {
      toggleAutoCommit = jdbcContext.connection().getAutoCommit();
      if ( log.isDebugEnabled() ) {
        log.debug("current autocommit status: " + toggleAutoCommit);
      }
      if (toggleAutoCommit) {
        log.debug("disabling autocommit");
        jdbcContext.connection().setAutoCommit(false);
      }
    }
    catch (SQLException e) {
      log.error("JDBC begin failed", e);
      throw new TransactionException("JDBC begin failed: ", e);
    }

    callback = jdbcContext.registerCallbackIfNecessary();

    begun = true;
View Full Code Here

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

    log.debug("commit");

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

    notifyLocalSynchsBeforeTransactionCompletion();
    if ( callback ) {
      jdbcContext.beforeTransactionCompletion( this );
    }

    try {
      commitAndResetAutoCommit();
      log.debug("committed JDBC Connection");
      committed = true;
      if ( callback ) {
        jdbcContext.afterTransactionCompletion( true, this );
      }
      notifyLocalSynchsAfterTransactionCompletion( Status.STATUS_COMMITTED );
    }
    catch (SQLException e) {
      log.error("JDBC commit failed", e);
      commitFailed = true;
      if ( callback ) {
        jdbcContext.afterTransactionCompletion( false, this );
      }
      notifyLocalSynchsAfterTransactionCompletion( Status.STATUS_UNKNOWN );
      throw new TransactionException("JDBC commit failed", e);
    }
    finally {
      closeIfRequired();
    }
  }
View Full Code Here

   * {@inheritDoc}
   */
  public void rollback() throws HibernateException {

    if (!begun && !commitFailed) {
      throw new TransactionException("Transaction not successfully started");
    }

    log.debug("rollback");

    if (!commitFailed) {

      /*notifyLocalSynchsBeforeTransactionCompletion();
      if ( callback ) {
        jdbcContext.notifyLocalSynchsBeforeTransactionCompletion( this );
      }*/

      try {
        rollbackAndResetAutoCommit();
        log.debug("rolled back JDBC Connection");
        rolledBack = true;
        notifyLocalSynchsAfterTransactionCompletion(Status.STATUS_ROLLEDBACK);
      }
      catch (SQLException e) {
        log.error("JDBC rollback failed", e);
        notifyLocalSynchsAfterTransactionCompletion(Status.STATUS_UNKNOWN);
        throw new TransactionException("JDBC rollback failed", e);
      }
      finally {
        if ( callback ) {
          jdbcContext.afterTransactionCompletion( false, this );
        }
View Full Code Here

          //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

    log.trace( "Attempting to locate UserTransaction via JNDI [{}]", utName );

    try {
      UserTransaction ut = ( UserTransaction ) getInitialContext().lookup( utName );
      if ( ut == null ) {
        throw new TransactionException( "Naming service lookup for UserTransaction returned null [" + utName +"]" );
      }

      log.trace( "Obtained UserTransaction" );

      return ut;
    }
    catch ( NamingException ne ) {
      throw new TransactionException( "Could not find UserTransaction in JNDI [" + utName + "]", ne );
    }
  }
View Full Code Here

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

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

  }
View Full Code Here

    log.debug("begin");
   
    boolean synchronization = jdbcContext.registerSynchronizationIfPossible();

    if ( !synchronization ) {
      throw new TransactionException("Could not register synchronization for container transaction");
    }

    begun = true;
   
    jdbcContext.afterTransactionBegin(this);
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.